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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 888 views
  • 3 likes
  • 2 in conversation