BookmarkSubscribeRSS Feed
VimalKurup
Calcite | Level 5

,Hi,

I am seeking your help in trying to resolve an issue which i am getting while generating the report. Report is generated as a PDF which has a mix of reports(generated using PROC REPORT statements) and text(ODS PDF TXT). When there is data in dataset then we use PROC REPORT to print else use ODS PDF TXT to provide a comment "No data found". There are about 4 datasets that are part of this report.

Sample Pseudocode

ODS PDF FILE= <destination>;

1. Check if data present in dataset - DataA.

     If yes

     PROC REPORT DATA=DataA;

     RUN;

     else

     ODS PDF TEXT='No data found';

This repeats for the 4 datasets.

Issue that i am facing is-

1. When there is no data present in DataA, the overall title which i want for the report is not getting published. The report starts with the text "No data found".

2. If i were to output the main title as PDF TEXT , then the remainder of the report is coming just as PDF TEXT and not print PROC REPORT outputs.

It would be great if i can just publish the titles when the dataset is empty and move forward. Is there any such means? Or a better suggestion to generate the report in itself.

Thanks in advance,

Vimal

7 REPLIES 7
Cynthia_sas
SAS Super FREQ

Hi:

  ODS PDF TEXT= does not trigger a title statement. Only a procedure will trigger a title statement. So you could do something like this instead of your current else branch (shown in pseudocode):

*** new else branch ***

data msg;

  length msg $100;

  msg="no data found';

run;

title 'The title you want';

proc report data=msg nowd noheader;

  column msg;

run;

*** end new else branch ***

cynthia

VimalKurup
Calcite | Level 5

Hi Cynthia,

Appreciate the time you took in responding to my query. Issue is resolved. I used PROC REPORT more or less similar to the one in your response.

Once again, Thanks !

Vimal

RW9
Diamond | Level 26 RW9
Diamond | Level 26

As Cynthia has stated, just add a step to check this.  Myself I generally do something like:

proc sql;

  create table TEST (a char(20),b num);

quit;

data _null_;

  set sashelp.vtable (where=(libname="WORK" and memname="TEST" and nobs=0));

  call execute('data test; msg="No data found"; output; run;');   /* will only be called if the dataset has 0 observations */

run;

VimalKurup
Calcite | Level 5

Thank you RW9

NWV
Calcite | Level 5 NWV
Calcite | Level 5

I realize this is an old thread....would it be possible to see full example code for something like this?  I have an ODS RTF report file I am creating for ~50 projects by macro.  There are 10 tables in each RTF report.  All created in proc print statements and controlling for labels, header alignment, etc., and it works fine.  EXCEPT, when one of the proc prints with a "where" statement resolves to no observations.  I still want the proc print titles to appear but there wouldn't be any table below it.  How can I trigger the titles if no data is retrieved by proc print?  Thank you.

Cynthia_sas
SAS Super FREQ
It doesn't matter whether you are talking about PROC REPORT or PROC PRINT, the code example shown in 2015 is the type of code you need to use. You cannot trigger just a title without SOMETHING else on the page. So making a dataset with an "error" message in the event of a WHERE that returns 0 obs is something you will have to code for.

cynthia
NWV
Calcite | Level 5 NWV
Calcite | Level 5

Thank you.

sas-innovate-2024.png

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.

 

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