The SAS Output Delivery System and reporting techniques

Macro Variable Issue and PDF

Reply
Frequent Contributor
Posts: 99

Macro Variable Issue and PDF

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!

SAS Super FREQ
Posts: 8,743

Re: Macro Variable Issue and PDF

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

Super User
Super User
Posts: 6,500

Re: Macro Variable Issue and PDF

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

SAS Super FREQ
Posts: 8,743

Re: Macro Variable Issue and PDF


Oh, good eyes, Tom!

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

cynthia

Ask a Question
Discussion stats
  • 3 replies
  • 216 views
  • 0 likes
  • 3 in conversation