BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
meckarthik
Quartz | Level 8

Hi, need help!!

when assigning macro to proc export, it works in data file i.e Reach_Report_&export  but not in outfile. My macro contains value as 2, it works in data = Reach_Report_2 but not in outfile. Any reasons and how to correct it?

 

proc export data=Report_2   outfile='\C:\Users\Incremental_Reach_Report_&export.xlsx'

dbms = xlsx replace;run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
heffo
Pyrite | Level 9

When using single quotes ' then SAS will not look to find macro references inside. You have to use double quotes for it to happen. 

 

Oh, and you will probably need to add another dot in there. 

Example:

%let export=myFile;
%put \C:\Users\Incremental_Reach_Report_&export.xlsx;
*This will then be translated to \C:\Users\Incremental_Reach_Report_myFilexlsx;
*The dot will be translated as the end of the macro variable, and it will be removed when the replacement is happening.;
*You want;
%put \C:\Users\Incremental_Reach_Report_&export..xlsx;
*This will then be translated to \C:\Users\Incremental_Reach_Report_myFile.xlsx;

View solution in original post

3 REPLIES 3
heffo
Pyrite | Level 9

When using single quotes ' then SAS will not look to find macro references inside. You have to use double quotes for it to happen. 

 

Oh, and you will probably need to add another dot in there. 

Example:

%let export=myFile;
%put \C:\Users\Incremental_Reach_Report_&export.xlsx;
*This will then be translated to \C:\Users\Incremental_Reach_Report_myFilexlsx;
*The dot will be translated as the end of the macro variable, and it will be removed when the replacement is happening.;
*You want;
%put \C:\Users\Incremental_Reach_Report_&export..xlsx;
*This will then be translated to \C:\Users\Incremental_Reach_Report_myFile.xlsx;
meckarthik
Quartz | Level 8

thank you, it helps

meckarthik
Quartz | Level 8

thank you !! it helps