@skynet wrote:
I have SAS macro ready which consumes Dir, file, var, data as input from user. But I have number of files and have to add these inputs manually which is time consuming when have to process 100s of file with macro. So, I have created excel sheet whose headers are same as macro's input and want to create SAS code which can read my excel and parse that data to macro and then macro will get triggered and I can get final outcome.
Dir
file
var
data
Dir1
file1
var1
data1
Dir2
file2
var2
data2
Dir3
file3
var3
data3
Dir4
file4
var4
data4
I have excel like above and have SAS macro ready.
So EXCEL has nothing to do with your actual problem. Get the data into a SAS dataset. If you already have it in an EXCEL sheet then use PROC IMPORT. Once you have it in a dataset use it from there.
It sounds like you want to use the data to generate calls to a macro. You don't mention the name of the macro, just the names of the parameters, so let's assume macro is named MYMACRO so we can write some example code.
First let's convert the listing you shared into a SAS dataset (since we don't have access to your actual dataset.)
data have;
input dir :$200. file :$200. var :$32. data :$200.;
cards;
Dir1 file1 var1 data1
Dir2 file2 var2 data2
Dir3 file3 var3 data3
Dir4 file4 var4 data4
;
Now we can use a data step to make a file that has one macro call per observation.
filename code temp;
data _null_;
set have;
file code;
put '%mymacro(' dir= ',' file= ',' var= ',' data= ')';
run;
Which will make a file that looks like this:
%mymacro(Dir=Dir1 ,file=file1 ,var=var1 ,data=data1 )
%mymacro(Dir=Dir2 ,file=file2 ,var=var2 ,data=data2 )
%mymacro(Dir=Dir3 ,file=file3 ,var=var3 ,data=data3 )
%mymacro(Dir=Dir4 ,file=file4 ,var=var4 ,data=data4 )
Which we could execute by using the %INCLUDE statement.
%include code / source2;
... View more