The SAS Output Delivery System and reporting techniques

Output just the title from PROC REPORT

Reply
Occasional Contributor
Posts: 5

Output just the title from PROC REPORT

,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

SAS Super FREQ
Posts: 8,739

Re: Output just the title from PROC REPORT

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

Occasional Contributor
Posts: 5

Re: Output just the title from PROC REPORT

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

Super User
Super User
Posts: 7,392

Re: Output just the title from PROC REPORT

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;

Occasional Contributor
Posts: 5

Re: Output just the title from PROC REPORT

Thank you RW9

Contributor NWV
Contributor
Posts: 29

Re: Output just the title from PROC REPORT

[ Edited ]

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.

SAS Super FREQ
Posts: 8,739

Re: Output just the title from PROC REPORT

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
Contributor NWV
Contributor
Posts: 29

Re: Output just the title from PROC REPORT

Thank you.

Ask a Question
Discussion stats
  • 7 replies
  • 690 views
  • 3 likes
  • 4 in conversation