Assume we have a data directory C:\temp\
which contains hundreds of Excel files, e.g. isin47.xls
and isin11.xls
. Of each Excel file I want to extract the value of cell $E$16
and create a long table result
which would look as follows, given the files had 299792458
and 662607004
as value in that cell, respectively.
isin value_euro
47 299792458
11 662607004
How do I do this most efficiently in SAS?
My idea so far is to the following algorithm:
- Loop over all files in a directory and create a table
myExcels
with all names, see How to iterate through files in SAS? - Loop over
myExcels
and import each of them with code something like
proc import
datafile="C:\temp\isin47.xls"
dbms=excelcs
out=data_current_isin
replace;
run;
proc sql;
select Value_found_in_E_1 into: value trimmed
from data_current_isin
where Value_found_in_D_1 = "Value_found_in_D_13";
quit;
%put ISIN 47 has value of &value. Euro;
- Collect all
&value.
in the tableresults
.
This approach has the problem, that it relies on values in Excel-cells $D$1
, $E$1
and $D$13
which is in general not the case, unless I write a VBA macro to populate the cells (which I want to avoid in favor of a pure SAS solution).
Looking forward to any comments or suggestions.
PS @allOutsideFinance: The ISIN uniquely defines a financial asset.
dbms=xlsx
which I was told by colleagues to avoid. I am now trying to understand why I should be usingdbms=excelcs
in my current project. – B--rianRANGE=
statement of PROC IMPORT works with theDBMS=XLS
source. What did you try? How did you specify the range? – Tom