@dmuzyka wrote:
Thank you,
I know I probably could've made a more convincing example since cylinders are already shown in table 1, but this is not my concern.
Your change to text does make the email more descriptive about the presence or absence of a table, but it does not fix the problem. My concern is that when no table is produced, the third table gets put on the same page where the second table would be. This creates a misleading page with the title "Second", the text for table 2, the text for table 3, and the third table (see attached pdf in my original post).
I have tried using the obpage statement with the after option in Proc Document, but I have not been able to introduce a page break.
Place the Title statement after the ODS text. If there is no proc output then the title won't appear.
I might also suggest routinely clearing Title statements at the end of procedures. I practically can't type Run; without having it followed by Title; to clear the titles.
Or delve into the macro language and conditional creation of output. I have macros for some common bits that test if the condition has any results and if so create at table, otherwise use Ods text or Proc Odstext to indicate no records were found. Depending on the version of SAS you are using you may be able to use %if %then %do in open code blocks. If there are records:
Proc sql noprint;
select count(*) into : varcount
from somedataset
where condition=somevalue
;
quit;
%if &varcount > 0 %then %do;
<your proc freq goes here>
%end;
%else %do;
<code to create empty table>
%end;
But you would have to indicate what the "empty table" should actually look like to get suggestions on creating one. Likely a Data _null_ step with some ODS _PUT_ statement or similar.
... View more