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.

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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