Hello all,
I have a shell script that runs a SAS program in batch and then emails me the results so I can visually check for anomalies. Some of the checks I run involve a PROC FREQ where an empty table means everything worked properly. My issue is that an empty table will not be generated and therefore throw off the notes and titles in the document I receive. My approach in SAS was to create multiple ODS documents as the quality checks are generated throughout the program, then replay them all at once using PROC DOCUMENT to write all the outputs to a single PDF that can be emailed to me. My generic code is as follows:
%let filehold = /filepath;
libname holding "/filepath";
ods _all_ close;
ods document name=holding.table1 ;
title "First";
ods text='For cylinders we need to visually check that most models have 4 or 6 cylinders, etc';
proc freq data=sashelp.cars;
table cylinders;
run;
ods document close;
ods document name=holding.table2;
title "Second";
ods text='The second table should be empty. No cars should have 14 cylinders';
proc freq data=sashelp.cars;
table cylinders / list;
where Cylinders = 14;
run;
ods document close;
ods document name=holding.table3;
title "Third";
ods text='For MPG we should not see any unreasonable values like 0 or 10000';
proc means data=sashelp.cars;
var MPG_City;
run;
ods document close;
ods pdf file="&filehold/results.pdf";
proc document name=holding.table1;
replay;
run;
quit;
proc document name=holding.table2;
replay;
run;
quit;
proc document name=holding.table3;
replay;
run;
quit;
ods pdf close;
Of the tables created, table 2 should be empty. My current results can be seen in the attached file. Is there something I can do to force a table from PROC FREQ even if it is empty? Or is there a way I could have PROC DOCUMENT insert a page break if the table being replayed is empty? Or is there a totally different approach I should consider?
I am using SAS 9.2
Thanks!