07-21-2015 09:49 AM
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.
ODS PDF FILE= <destination>;
1. Check if data present in dataset - DataA.
PROC REPORT DATA=DataA;
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,
07-21-2015 07:11 PM
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 ***
length msg $100;
msg="no data found';
title 'The title you want';
proc report data=msg nowd noheader;
*** end new else branch ***
07-23-2015 09:42 AM
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 !
07-23-2015 09:49 AM
As Cynthia has stated, just add a step to check this. Myself I generally do something like:
create table TEST (a char(20),b num);
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 */
07-14-2016 11:47 AM - edited 07-14-2016 11:48 AM
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.
07-14-2016 03:56 PM