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 (December 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 3 Dec 2008 10:02:19 -0500
Reply-To:   "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Subject:   Re: Implicit Arrays and DO OVER
In-Reply-To:   <ce1fb7450812030152x12082d63g2675188664edf89c@mail.gmail.com>
Content-Type:   text/plain; charset=us-ascii

I think a quiet session of RTFM is appropriate here in order to make sure we understand exactly what _temporary_ is supposed to do.

From the OnLine Doc: arrays assigning initial values to elements

page title: Array Processing

Examples of Array Processing

....

Example 3: Creating an Array for Temporary Use in the Current DATA Step

When elements of an array are constants that are needed only for the duration of the DATA step, you can omit variables from an array group and instead use temporary array elements. You refer to temporary data elements by the array name and dimension. Although they behave like variables, temporary array elements do not have names, and they do not appear in the output data set. Temporary array elements are automatically retained, instead of being reset to missing at the beginning of the next iteration of the DATA step.

To create a temporary array, use the _TEMPORARY_ argument. The following example creates a temporary array named TEST:

options nodate pageno=1 linesize=80 pagesize=60;

data score2(drop=i); array test{3} _temporary_ (90 80 70);

> -----Original Message----- > From: owner-sas-l@listserv.uga.edu > [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of ./ ADD > NAME=Data _null_, > Sent: Wednesday, December 03, 2008 4:52 AM > To: Akshaya Nathilvar > Cc: SAS-L@listserv.uga.edu > Subject: Implicit Arrays and DO OVER > > On 12/2/08, Akshaya Nathilvar <akshaya.nathilvar@gmail.com> 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; > _i_=2; > 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); > A=abc; > B=xyz; > output; > end; > keep ID A B; > put _all_; > Run; > >


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