BookmarkSubscribeRSS Feed
RobertNYC
Obsidian | Level 7

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!

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

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

Tom
Super User Tom
Super User

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={}';

Cynthia_sas
SAS Super FREQ


Oh, good eyes, Tom!

I didn't notice the double quotes on the %LET statement. Good catch!

cynthia

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 3 replies
  • 722 views
  • 0 likes
  • 3 in conversation