Date: Wed, 3 Dec 2008 03:52:05 -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: Implicit Arrays and DO OVER
Content-Type: text/plain; charset=ISO-8859-1
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 ;
> 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;
> keep ID A B;
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.
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;