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
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
data _null_ ;
put nobs= ;
call symputx ('nobs', nobs) ;
set myds nobs = nobs ;
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.
On Mon, 7 Jul 2008 13:50:04 -0400, Talbot Michael Katz <topkatz@MSN.COM> wrote:
>I was experimenting with the following code in SAS 9.01.01M3P020206 on
> set myds (obs=&obsn.) nobs=nobs;
> put nobs=;
> call symput ("nobs",nobs);
>%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?
>-- TMK --
>"The Macro Klutz"