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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1026 views
  • 3 likes
  • 2 in conversation