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 (December 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 3 Dec 2008 17:16:03 +0000
Reply-To:     karma <dorjetarap@GOOGLEMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         karma <dorjetarap@GOOGLEMAIL.COM>
Subject:      Re: avoid making macro just to use %if,
              %then logic to selectively process code?
Comments: To: jrholdcraft@aep.com
In-Reply-To:  <OF5BC6DFFA.4757E157-ON85257514.00453496-85257514.00469574@aep.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi Jennifer,

If you are running the program in batch mode, putting the following code at the start of the program should terminate it - and therefore not run the remainder of your program - if the dataset of interest doesn't exist, or has no values. In interactive mode, this will only terminate the current datastep.

HTH

data _null_; dsid=open('sashelp.fake'); if dsid; check=attrn(dsid,'nobs'); if ^(dsid or check) then abort return; run;

2008/12/3 Jennifer R. Holdcraft <jrholdcraft@aep.com>: > All, > > I have some SAS programs that do various processing and call "real" macros > (I don't know how else to phrase it - I mean macros that actually have > parameters that need to be submitted to them), but lately we've had some > significant changes to the type of deals that we make (i.e. we always used > to have options of certain commodities but they have expired and the group > isn't making that kind of deal anymore - or at least not for a while - > which is why I don't want to remove the code completely) and some programs > are now failing because the incoming datasets are non-existent/empty. > > The only way I know to selectively process the code is to use %if %then > type logic at the beginning to check to see if the incoming data exists or > has 0 records and depending on the 1/0 result of this decide to process > the code, or issue a %goto quit statement (quit is defined as quit: at the > very bottom of the program) - and this necessitates the code being inside > a macro. So I'm basically having to define a macro without any parameters > around the code and then call this macro at the bottom of the program. > > Is there any way to do that checking of incoming datasets and selective > processing of code without defining that "dummy" macro around it? It > somehow seems ugly to me. > > Thanks, > > Jennifer > > Jennifer R. Holdcraft > System Analyst, Market Risk Analytics > American Electric Power > 614-583-6761, Audinet 220-6761 > Cell: 614-307-4258 > jrholdcraft@aep.com >


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