Date: Fri, 20 Mar 2009 04:33:36 -0400
Reply-To: Jim Groeneveld <jim.1stat@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jim Groeneveld <jim.1stat@YAHOO.COM>
Subject: Re: Testing for the existence of a dataset with more than 0
observations?
Hi David,
To test for the existence of a dataset is done with the SAS function EXIST.
See your SAS documentation on examples of use, also in SAS macro code.
To check the amount of records is done with the option NOBS=variable of the
SET statement. See your documentation.
Examples:
%LET Check = %SYSFUNC(EXIST(dataset));
%LET NofCases = ;
%MACRO DoBlock;
%IF (&Check EQ 1) %THEN %DO;
DATA _NULL_;
IF 0 THEN SET dataset NOBS=NofCases;
CALL SYMPUT ('NofCases', LEFT(PUT(NofCases,8.)));
STOP;
RUN;
%END;
%MEND DoBlock;
%PUT Existence of dataset = &Check;
%PUT Dataset has &&NofCases number of records;
Regards - Jim.
--
Jim Groeneveld, Netherlands
Statistician, SAS consultant
home.hccnet.nl/jim.groeneveld
My computer, my wife and I will attend SGF 2009 near Washington.
On Thu, 19 Mar 2009 21:05:13 -0400, David Friedman
<harrypotterdhf@EARTHLINK.NET> wrote:
>If I wanted to test both the existence of a dataset and also to make sure
>it was not empty what is the best way to accomplish this. I have SAS 8.2
>installed here.