Date: Wed, 3 Dec 2008 09:00:06 -0600
Reply-To: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Subject: Re: Implicit Arrays and DO OVER
Content-Type: text/plain; charset=ISO-8859-1
I agree, and started to mention something similar but didn't want to
hear from the "but I like DO OVER and Implicit arrays" crowd.
The post from Akshaya's is a perfect example of confusion cause by
using a feature that is not well understood/documented. That's why I
posted what was intended to be a clarification not an endorsement. I
"never" use them myself. But I never say never.
On 12/3/08, Mike Rhoads <RHOADSM1@westat.com> wrote:
> I just had to stick in my two cents -- in my personal opinion, anyway, new programs should NOT use features that are "deprecated" (i.e. still in the language for compatibility, but no longer documented), if for no other reason that it may seriously puzzle a later programmer who comes along and does not know (and can't find documentation for) the syntax.
> I'm not sure whether it would help or hurt if SAS maintained an official / available list of such deprecated features ... ;-)
> Mike Rhoads
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of ./ ADD NAME=Data _null_,
> Sent: Wednesday, December 03, 2008 4:52 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Implicit Arrays and DO OVER
> On 12/2/08, Akshaya Nathilvar <firstname.lastname@example.org> wrote:
> > I take that back, looks like adding _TEMPORARY_ keyword to the array
> > statement avoids the OUT OF RANGE error message:
> > For example:
> > Data have;
> > input ID $ A1 A2 A3 B1 B2 B3 B4 b5 ;
> > cards;
> > QQ 1 2 3 5 2 4 9 10
> > GG 3 8 3 6 7 4 9 10
> > WW 4 5 6 6 1 8 9 10
> > ;
> > Data want;
> > set have;
> > array abc a1-a3 _temporary_ _temporary_;
> > array xyz b1-b5;
> > do over abc;
> > A=abc;
> > B=xyz;
> > output;
> > end;
> > keep ID A B;
> > Run;
> > Akshaya!
> To me this statement implies some misunderstanding of implicit array
> declarations and reference.
> ARRAY arrayname(index variable) <list of names>;
> The default index variable is _I_.
> To reference this type of array you first set the value of the index
> variable and then use the array name.
> array imp a b c;
> imp = 100;
> x = imp;
> The value of variable b, array element 2 is assigned the value 100.
> Then x is given the same value.
> DO OVER is simply short hand for
> DO indexVariable = 1 to dim(array);
> When DO OVER was "king" I don't recall there being a DIM function so
> you can see how the syntax was quite useful.
> It should also be noted that the elements of an implicit array can be
> a list of implicit arrays. Arrays of arrays.
> Akshaya's data step modified slightly to show the definitions of the
> implicit elements more explicitly. _TEMPORARY_ is a variable name
> when used in this context.
> Data want;
> set have;
> array abc(_i_) a1-a3 _temporary_ _temporary_;
> array xyz(_i_) b1-b5;
> *do over abc;
> do _i_ = 1 to dim(abc);
> keep ID A B;
> put _all_;