BookmarkSubscribeRSS Feed
BigD
Calcite | Level 5

Hi,

I want to write a line in a report that is execute only is there is missing data. As an example below: New York does not report so I would like to print that in my report and not print anything is all sites report. I've gotten this far, but don't know how to produce the ods pdf text statement dynamically.

ods pdf;

data test_data;

input site  $30. ;

cards;

Dallas Ft Worth

Cleveland

Chicago

;

run;

data lookup;

input facility $30. ;

cards;

Dallas Ft Worth

Cleveland

Chicago

New York

;

run;

proc sql;

create table WhoIsMissing

as select a.site, b.facility

from test_data as a

right join lookup as b

on a.site=b.facility;

quit;

/*put the name into a macro variable;*/

proc sql noprint;

select  facility into:missing

from whoismissing

where site='';

quit;

%put &missing;

/*If there is no value in the macro variable then do nothing.*/

/*if there is a data value in the macro variable the print it*/

/*stumped here on how to do this dynamically*/

/*Also not sure how to deal with two or more missing sites*/

Ods pdf text="^S={font=('Arial' ,12pt, bold ) just=center } Site &Missing is missing";

ods pdf close;

3 REPLIES 3
Reeza
Super User

1. %if %then %do to control macro execution:

%macro test(value);

%if &value=%str() %then %do;

%put "Macro Variable is empty";

%end;

%else %do;

%put "Macro Variable is:" &value;

%end;

%mend;

%test();

%test(one);

%test(23);

%test();

%test(3kdjklfa);

BigD
Calcite | Level 5

Thanks. Works nicely.

Bruce

cathyhill
Calcite | Level 5

First, thank you so much for posting this pdf editing issue here.Smiley Happy Since you have solved the pdf text processing problem, would you please mark it as solved. Thanks.Smiley Wink

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2245 views
  • 0 likes
  • 3 in conversation