Date: Mon, 7 Aug 2000 13:46:50 -0400
Reply-To: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject: Re: Empty dataset - special variable
data testdata; stop; run;
if _n_=1 and done then do;
set testdata end=done;
As coded, TESTDATA will have zero observations. Then rerun, but comment out
the STOP statement so that TESTDATA has one observation.
The conditional code has to come before the SET statement.
There are two possibilities.
1. If there is at least one observation in TESTDATA, the condition in the IF
statement will never be true.
2. If TESTDATA is empty, the condition will be true as execution starts.
Execution will terminate when the SET statement fails.
On Mon, 7 Aug 2000 11:10:30 -0500, Shawn Ribordy <Ribordy_Shawn_C@CAT.COM>
>I have been working in a DATA _NULL_ step and I encounter an error in my
>process if I set an empty dataset into the DATA _NULL_ step.
>I want to output some default values if the dataset contains no
>records. Is there a special variable that contains the number of
>records in a dataset?
>For example, I want to do this
>IF OBSERVATIONS > 0 THEN DO;
> normal processing;
> default values here;