|Date: ||Wed, 28 Jan 2004 11:44:24 +0530|
|Reply-To: ||"Yerramsetty, Naveen Kumar (Cognizant)"
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||"Yerramsetty, Naveen Kumar (Cognizant)"
|Subject: ||Re: how-to stop datasteps if nobs=0 in macro|
I have sample macro code which tests for DS and if it exists assigns the no of obs and no of vars to global variables.
You can use these global variables to find out the number of obs.
Hope this helps you.
%GLOBAL dset nvars nobs;
%let dsid = %sysfunc(open(&dset));
%if &dsid %then
%let nobs =%sysfunc(attrn(&dsid,NOBS));
%let rc = %sysfunc(close(&dsid));
%put Open for data set &dset failed - %sysfunc(sysmsg());
From: Arto Raiskio [mailto:arto-nospam@RAISKIO.COM]
Sent: Sunday, January 25, 2004 5:01 PM
Subject: how-to stop datasteps if nobs=0 in macro
I have some macrocode which looks like the following sample and the question
is how to best stop the code so that the proc printto is not executed and
Zero byte reports files written (empty report files)
code runs on windows, sas is version 9
proc ..(some procstep)
proc printto file= (this would write output to a file if records exist)
normally, on a mainframe job, one could use something like
data _null_;set a nobs=nobs; if nobs=0 then abort abend 0001;run;
what might be the easiest way to stop the macro just before the proc printto
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly
prohibited and may be unlawful.
Visit us at http://www.cognizant.com