0
votes

I want to be able to print all of my reports to external files but only display a select few in the results viewer. In the below example I want reportA and reportB to be displayed AND printed (file.xls) but reportC to be printed to a separate file (file2.csv) and not displayed in the results viewer. Any ideas?

ods msoffice2k file="/file/file.xls";
proc print data=reportA;
run;
proc print data=reportB
run;
ods msoffice2k close;
ods csvall file="/file/file2.csv";
proc print data=reportC;
run;
ods csvall close;
3

3 Answers

1
votes

You can also use ODS EXCLUDE and ODS SELECT to target specific destinations.

For example, ods html select none; will turn off the HTML destination temporarily, but not actually close it - it just won't get any results for a while. You can then use ods html select all; to turn it back on.

You can also use ods html exclude all; to do the same thing and then turn it back on with ods html exclude none;.

With either statement, you can also use a where statement in the ods select/exclude to filter to only affect one specific part of an output. See the documentation for more details.

0
votes

Close the list output which is the default. OR the HTML if that is the default results window in your system. Re-open the output after the file is created.

ods msoffice2k file="/file/file.xls";
proc print data=reportA;
run;
proc print data=reportB
run;
ods msoffice2k close;
ods listing close;
ods html close;
ods csvall file="/file/file2.csv";
proc print data=reportC;
run;
ods csvall close;
ods listing;
ods html;
0
votes

I actually found a better solution through using the proc export feature for suppressing display of the csv output.

ods msoffice2k file="/file/file.xls";
proc print data=reportA;
run;
proc print data=reportB
run;
ods msoffice2k close;

proc export data=reportC
outfile="/file/file2.csv"
dbms=dlm
replace;
delimiter=",";
run;

Thanks for the help @Reeza I'll keep those settings in mind for future projects.