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

Hi everyone,

 

My dataset has 18 schools in total. I have a macro written to output .rtf files by school. 

 

I'd like the macro to generate an automated file name for each school, for instance:

 

Profile_School of Business_&SYSDATE9.rtf

Profile_School of Engineering_&SYSDATE9.rtf

 

But instead, this happened:

Profile_put(int_frrpt, $intmaj.)_19SEP2019.rtf

 

What am I doing wrong?

My code:

 

 

 

proc format;
value $intmaj 
'BUS'='School of Business' 
'ENGI'='School of Engineering';
run;

%macro Run_Tabulate2 (school=);
ODS RESULTS OFF;
options orientation=landscape NODATE NOSTIMER NONUMBER NOBYLINE;
%let schl = put(int_frrpt, $intmaj.); 

ods rtf file="&root.\Output\Profile_&schl._&SYSDATE9..rtf" startpage=no BODYTITLE_AUX cssstyle="&root.\style.css";

ods escapechar='^';

proc tabulate;
** Insert misc stats by school here;
run;
ods rtf close;
%mend;

%Run_Tabulate2 (school='BUS'); 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The macro language is just a text replacement system, so you will have the text

put(int_frrpt, $intmaj.)

inserted where you use &schl.:

Output\Profile_&schl._

thus turns into

Output\Profile_put(int_frrpt, $intmaj.)_

and since data step functions are not executed in this place, you end up with the text that surprises you.

Also, you could only resolve the text "int_frrpt", but never the contents of a variable called int_frrpt.

Change your %let to

%let schl = %sysfunc(putc(&school.,$intmaj.)); 

 

 

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

The macro language is just a text replacement system, so you will have the text

put(int_frrpt, $intmaj.)

inserted where you use &schl.:

Output\Profile_&schl._

thus turns into

Output\Profile_put(int_frrpt, $intmaj.)_

and since data step functions are not executed in this place, you end up with the text that surprises you.

Also, you could only resolve the text "int_frrpt", but never the contents of a variable called int_frrpt.

Change your %let to

%let schl = %sysfunc(putc(&school.,$intmaj.)); 

 

 

lin39
Obsidian | Level 7

Thanks so much for the explanation. However when I tried to used your code, I got Profile_'BUS'_19SEP2019.rtf. Any ideas?

Tom
Super User Tom
Super User

@lin39 wrote:

Thanks so much for the explanation. However when I tried to used your code, I got Profile_'BUS'_19SEP2019.rtf. Any ideas?


Does the format actually know how to decode the value 'BUS' instead of BUS?  If not then don't include the single quotes in the value of the macro variable.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 3595 views
  • 2 likes
  • 3 in conversation