Date: Mon, 7 Jul 2008 12:19:13 -0700
Reply-To: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject: Re: SET with OBS=0
Content-Type: text/plain; charset=iso-8859-1
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On
> Behalf Of Scott Barry
> Sent: Monday, July 07, 2008 11:47 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: SET with OBS=0
> On Jul 7, 1:58 pm, Nord...@DSHS.WA.GOV ("Nordlund, Dan (DSHS/RDA)")
> > > -----Original Message-----
> > > From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On
> > > Behalf Of Talbot Michael Katz
> > > Sent: Monday, July 07, 2008 10:50 AM
> > > To: SA...@LISTSERV.UGA.EDU
> > > Subject: SET with OBS=0
> > > Hi.
> > > I was experimenting with the following code in SAS
> 9.01.01M3P020206 on
> > > HPUX:
> > > %let obsn=0;
> > > data _null_;
> > > set myds (obs=&obsn.) nobs=nobs;
> > > put nobs=;
> > > call symput ("nobs",nobs);
> > > run;
> > > %put nobs = &nobs.;
> > > The put statement produced no output and the %put issued a
> > > warning that
> > > nobs did not resolve. If I change macro variable obsn to 1 then
> > > everything works okay. I wanted to use SET with OBS=0 as a
> > > way of getting
> > > some information, like the number of observations,
> without actually
> > > reading any observation information into the data vector.
> > > there are alternatives, such as OPEN and ATTRN, but my
> questions are:
> > > Is there a way to get the number of observations from SET
> > > and OBS=0 (in
> > > other words, did I do something wrong)?
> > > What information can you get from SET and OBS=0, if anything?
> > > Thanks!
> > > -- TMK --
> > > "The Macro Klutz"
> > I think what you are looking for is
> > data _null_;
> > id 0 then set myds nobs=nobs;
> > put nobs=;
> > call symput ("nobs",nobs);
> > run;
> > Hope this is helpful,
> > Dan
> > Daniel J. Nordlund
> > Washington State Department of Social and Health Services
> > Planning, Performance, and Accountability
> > Research and Data Analysis Division
> > Olympia, WA 98504-5204- Hide quoted text -
> > - Show quoted text -
> The CALL SYMPUT statement must occur before the SET statement, so that
> it gets invoked with a zero obs condition. And also code a SAS STOP
> statement after the SET so that the entire input file is not passed
> when there are observations.
> Scott Barry
> SBBWorks, Inc.
Why do you say the CALL SYMPUT must occur before the SET statement here? The data step stores the number of obs in the macro variable just fine as written. In addition, no observations are read because the SET statement is never executed, and the data step ends after the first pass. What am I missing?
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204