Date: Fri, 24 Dec 2004 09:03:24 -0500
Reply-To: Venky Chakravarthy <venky.chakravarthy@PFIZER.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Venky Chakravarthy <venky.chakravarthy@PFIZER.COM>
Subject: Re: Order of FIRST. / LAST. variables in PDV
Others have already mentioned what a clever idea this is. Well, if you are
asking for guarantees there may be none. FIRST. and LAST. variables are
available for all the variables in the data set, not merely the ones in the
BY statement. You have already acknowledged that variable names beginning
with FIRST is a potential pitfall. In addition, while unlikely, if someone
gets really clever and codes as below it provides another counter example.
22 data q ;
23 array a (3) ;
24 retain a 1 ;
25 run ;
NOTE: The data set WORK.Q has 1 observations and 3 variables.
NOTE: DATA statement used:
real time 0.01 seconds
cpu time 0.00 seconds
27 data why ;
28 first.a3 = 50 ;
29 set q ;
30 by a1 a2 ;
31 array first[*] first: ;
33 do I=1 to dim(first);
34 * Retrieve name minus 'FIRST.';
35 x = substr(vname(first[I]), 7);
36 put x=;
On Thu, 23 Dec 2004 13:13:26 -0800, m n <iced_phoenix_news@YAHOO.COM> wrote:
>Does anyone know if there is a (*documented*)
>guarantee that the order of the FIRST./LAST. variables
>in the PDV will be the same as the order of variables
>in the expanded by-variable list?
> set &DATA;
> by &COMPLICATED_BY_VARIABLE_LIST;
> array first[*] first: ;
> do I=1 to dim(first);
> * Retrieve name minus 'FIRST.';
> x = substr(vname(first[I]), 7);
> put x=;
>Is there any guarantee that the FIRST. variable
>ordering will line up with the expanded by-variable
>ordering (so that I can expand the complicated
>This works in my experiments, but I can't find
>documentation about this, and so I hate to rely upon
>"seems to work" rather than "guaranteed to work".
>Thanks for your help!
><ASIDE> The above code breaks if you have variables in
>the data step that begin with 'First' (other than the
>'First.' variables). SAS does not allow First.:,
>Do you Yahoo!?
>Send a seasonal email greeting and help others. Do good.