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 (July 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 8 Jul 2008 09:11:49 -0400
Reply-To:     Paul Dorfman <sashole@BELLSOUTH.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul Dorfman <sashole@BELLSOUTH.NET>
Subject:      Re: SET with OBS=0
Comments: To: Talbot Michael Katz <topkatz@MSN.COM>

TMK,

Your goal is:

1) to let the compiler to see a syntactically valid reference to MYDS 2) to execute PUT and SYMPUT before the step quits run-time execution

Hence

data _null_ ; put nobs= ; call symputx ('nobs', nobs) ; stop ; set myds nobs = nobs ; run ;

will work because there is a syntacticaly valid reference to MYDS which the compiler heeds reading NOBS from the descriptor before any run-time execution starts, and during the run-time PUT and SYMPUT execute before the step stops using NOBS value placed in the PDV by the compiler.

Note that the above will also work with

set myds (obs = 0) nobs = nobs ;

because this is also a syntatically valid reference to MYDS. In your case, it did not work because an attempt was made to read from the empty MYDS buffer causing the step to quit before PUT/SYMPUT could execute.

There is no mystery in how simple things like this work; one only have to firmly understand the principles of compile/run-time timings.

Kind regards ------------ Paul Dorfman Jax, FL ------------

On Mon, 7 Jul 2008 13:50:04 -0400, Talbot Michael Katz <topkatz@MSN.COM> wrote:

>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. Obviously, >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"


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