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 (March 2002, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 4 Mar 2002 13:34:49 -0500
Reply-To:     Charles Patridge <Charles_S_Patridge@PRODIGY.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Charles Patridge <Charles_S_Patridge@PRODIGY.NET>
Subject:      Re: how to stop creating a data set
Comments: To: "P. L" <li_9@HOTMAIL.COM>

Dear PI,

What you can do is test to see if you have an empty dataset and then determine what you want to do - that is skip some logic or execute some logic (such as delete a dataset).

Here is some code to get the number of OBS in a datatset (not the most efficient method but it does work).

*********************************************************************; ** PROGRAM: EMPTYYN (MACRO) ; ** AUTHOR: CHUCK PATRIDGE ; ** DATE: 10/12/94 ; ** PURPOSE: DETERMINE IF A SAS DATASET IS EMPTY. ; ** INPUT PARAMETER: DSNAME (NAME OF SAS DATA SET) ; ** ALSO CAN BE BLANK ( USE LAST DATASET CREATED) ; ** OUTPUT: WILL CREATE THE FOLLOWING GLOBAL MACRO VARIABLES ; ** EMPPTYYN Y=EMPTY, N=NONEMPTY ; ** NUMOBS WHICH PROVIDES NUMBER OF RECORDS ; ** DSN WHICH PROVIDES NAME OF DATA SET ; ** SAMPLE CALL: %EMPTYYN(DATASET) ; ** ; *********************************************************************; %GLOBAL EMPTYYN NUMOBS DSN; %MACRO EMPTYYN(DSNAME); DATA _NULL_; IF "&DSNAME " = " " THEN CALL SYMPUT('DSNAME','_LAST_'); RUN;

DATA _NULL_; IF 0 THEN SET &DSNAME NOBS=NUMOBS; IF NUMOBS > 0 THEN EMPTYYN = 'N'; ELSE EMPTYYN = 'Y'; CALL SYMPUT('EMPTYYN',PUT(EMPTYYN, $1.)); CALL SYMPUT('NUMOBS' ,PUT(NUMOBS , BEST.)); CALL SYMPUT("DSN" ,PUT("&DSNAME" , $VARYING17.)); STOP; RUN; %MEND EMPTYYN; ******** END OF SAS PROGRAM ****************;

You only need to use the maco variable "numobs", the other two are not needed in your case.

HTH, Charles Patridge Email: Charles_S_Patridge@prodigy.net


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