Hi all--
I’m having trouble generating a macro value in a dataset I use to create a title page in a PDF.
The macro variable is agyname:
%let agyname="Agency ABC";
So instead for the title reading “Agency ABC” the program prints “&agyname”
Below is where I create a dataset for the title page. Notice where I have written the macro variable &agyname.
data work.title;
drop i;
length line $200;
do i = 1 to 6 by 1;
line = ' ';
output;
end;
line = "^S={font_size=16pt}2012 Agency Regular Medical Review";
output;
line = '^S={font_size=15pt}'
||'&agyname^S={}';
output;
line = "^S={background=black cellheight=.5pt font_size=1pt cellpadding=0}"
||' '||"^S={}";
output;
do i = 1 to 2 by 1;
line = ' '; output;
end;
output;
line = '^S={font_size=13pt font_face=Arial}'
||'Medical Unit'
||'^S={}';
output;
line = '^S={font_size=13pt font_face=Arial}'
||"Administration "
||'^S={}';
output;
do i = 1 to 2 by 1;
line = ' ';
output;
end;
run;
Below is the proc report statement I use to bring in the title data for the the pdf report
proc report data=work.title noheader nowd
style={rules=none frame=void just=c
cellspacing=0 cellpadding=4pt};
column line;
define line /
style(column)={just=c font_weight=bold
font_face=Arial
foreground=black};
ods pdf startpage=no;
run;
Any help is greatly appreciated!
Hi:
Macro variables do NOT resolve within single quotes:
line = '^S={font_size=15pt}' ||'&agyname^S={}';
so I'd suggest that you try to replace your single quotes with double quotes:
line = '^S={font_size=15pt}' || "&agyname^S={}" ;
cynthia
Macro variable references do not resolve inside of single quotes.
%let agyname="Agency ABC";
So where you have :
line = '^S={font_size=15pt}'||'&agyname^S={}';
You are setting the value of the dataset variable LINE to
'^S={font_size=15pt}&agyname^S={}'
But you probably want it to instead be this value:
'^S={font_size=15pt}Agency ABC^S={}'
You already included double quotes around your macro variable's value so you can write that statement this way:
line = '^S={font_size=15pt}'||&agyname||'^S={}';
If you removed the quotes from around the value of the macro variable in your %LET statement then you would want to write the assignment statement this way:
line = '^S={font_size=15pt}'||"&agyname"||'^S={}';
Oh, good eyes, Tom!
I didn't notice the double quotes on the %LET statement. Good catch!
cynthia
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.