As an alternative to other, more global solutions, take a look at this
create table print as
select * from test
proc sql noprint;
select count(*) into :__n from print
%if (&___n ne 0) %then %do; proc print data=print;
%else %do; proc print data=noprint noobs;
Since the SELECT INTO clause instantiates the macrovariable __n, the test of
the macrovariable value follows creation of the dataset named 'print'.
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Michael
Sent: Monday, October 18, 2004 2:26 PM
Subject: Create Output Identifying No Records Found
We have a program that creates a SAS dataset, called "COSTS", that contains
data from different sources for one health record number. This is printed to
a LST file.
If no records are found, no LST file is created. If this is the case, we
want the user to know that no records were found when they go to the LST
file. Otherwise the LST file contains the relevant cost data.
What SAS code will do this?