LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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

Try this.

data testdata; stop; run;

data _null_; if _n_=1 and done then do; put 'Empty!'; end; set testdata end=done; put _all_; run;

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> wrote:

>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 > >DATA _NULL_; >SET TESTDATA; >IF OBSERVATIONS > 0 THEN DO; > normal processing; >END; >ELSE DO; > default values here; >END;


Back to: Top of message | Previous page | Main SAS-L page