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

I have the following simple macro

%macro hospseq (DSN=,NDSN=);

 

data new2019; set &DSN; run; %YEARSTEP(YEAR =2019 );


proc datasets library=work nolist; change cake2_2019=&NDSN; quit; run;


proc export data=&NDSN outfile="s:\smm\excel\&ndsn" dbms=csv replace; run;

 

%mend hospseq;

 

When I run the macro using the parameters below it produces the output file MS2019_ALLcsv.  What do I need to do to make the macro produce the CSV file with the CSV extension. So I get

MS2019_all.CSV instead of MS2019_allcsv .  If  I manually rename the file from MS2019_allCSV to MS2019_All.CSV the file is in the proper format.  Thanks for any suggestions.

Larry

%HOSPSEQ(DSN=smm2019,NDSN=MS2019_All);

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@Larry3Smith wrote:

I have the following simple macro

%macro hospseq (DSN=,NDSN=);

 

data new2019; set &DSN; run; %YEARSTEP(YEAR =2019 );


proc datasets library=work nolist; change cake2_2019=&NDSN; quit; run;


proc export data=&NDSN outfile="s:\smm\excel\&ndsn" dbms=csv replace; run;

 

%mend hospseq;

 

When I run the macro using the parameters below it produces the output file MS2019_ALLcsv.  What do I need to do to make the macro produce the CSV file with the CSV extension. So I get

MS2019_all.CSV instead of MS2019_allcsv .  If  I manually rename the file from MS2019_allCSV to MS2019_All.CSV the file is in the proper format.  Thanks for any suggestions.

Larry

%HOSPSEQ(DSN=smm2019,NDSN=MS2019_All);

 


Probably need to show us the code in that YEARSTEP macro as none of the code you show creates anything ending in CSV.

 

Somewhere you likely have a macro variable followed by .csv that needs to have ..csv.

Example:

%let var=ABC;

%put &var.csv;

%put &var..csv;

 

The macro language uses a single dot to indicate the end of the variable. So you need to have the second to be in the resolved value.

View solution in original post

2 REPLIES 2
ballardw
Super User

@Larry3Smith wrote:

I have the following simple macro

%macro hospseq (DSN=,NDSN=);

 

data new2019; set &DSN; run; %YEARSTEP(YEAR =2019 );


proc datasets library=work nolist; change cake2_2019=&NDSN; quit; run;


proc export data=&NDSN outfile="s:\smm\excel\&ndsn" dbms=csv replace; run;

 

%mend hospseq;

 

When I run the macro using the parameters below it produces the output file MS2019_ALLcsv.  What do I need to do to make the macro produce the CSV file with the CSV extension. So I get

MS2019_all.CSV instead of MS2019_allcsv .  If  I manually rename the file from MS2019_allCSV to MS2019_All.CSV the file is in the proper format.  Thanks for any suggestions.

Larry

%HOSPSEQ(DSN=smm2019,NDSN=MS2019_All);

 


Probably need to show us the code in that YEARSTEP macro as none of the code you show creates anything ending in CSV.

 

Somewhere you likely have a macro variable followed by .csv that needs to have ..csv.

Example:

%let var=ABC;

%put &var.csv;

%put &var..csv;

 

The macro language uses a single dot to indicate the end of the variable. So you need to have the second to be in the resolved value.

Larry3Smith
Calcite | Level 5
Thanks so much. I changed the part of the proc export outfile to &ndsn..csv and it works great now. Thanks again.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 952 views
  • 0 likes
  • 2 in conversation