user1652926
user1652926

Reputation: 85

How to import and export multiple data using sas macro?

Hi I am trying to do a macro in sas to the following function

I have multiple sas files(apr12part1, apr12part2,...,aug12part1,aug12part2), for each file(for example:apr12part1) , I will do some process which will give me three output(for example: apr12part1out1,apr12part1out2,pr12part1out3).

I was trying to use macro, but was not very sucssesful. Can someone help me with it? Thank you very much! The code I was using is something like this

%macro test(month=,part=);
   ...FROM EC100002.&month_part_&part
   ...
   proc export data=SASUSER.Out1 outfile='G:\Output\Output1_&month_&part.csv' dbms=csv replace;
   proc export data=SASUSER.Out2 outfile='G:\Output\Output2_&month_&part.csv' dbms=csv replace;
   proc export data=SASUSER.Out3 outfile='G:\Output\Output3_&month_&part.csv' dbms=csv replace;
   run;
%mend test

%test(month=apr12,part=1)

Upvotes: 1

Views: 2676

Answers (1)

BellevueBob
BellevueBob

Reputation: 9618

Try adding "dots" to concatenate the macro variables into a complete string. Also, you must use double-quotes, not single-quotes. Something like this:

proc export data=SASUSER.Out1 
     outfile="G:\Output\Output1_&month._&part..csv" dbms=csv replace;

Note there are two "dots" after your &part variable; the first is a concatenation operator and the second is part of the file name.

You probably have similar issues with the code not displayed, so check that as well.

Upvotes: 2

Related Questions