Date: Wed, 30 Jul 2003 04:59:52 +0000
Reply-To: sashole@bellsouth.net
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul Dorfman <paul_dorfman@HOTMAIL.COM>
Subject: Re: array processing
Content-Type: text/plain; format=flowed
>From: Jonathan Siegel <jmsiegel@YAHOO.COM>
>
>As Dale points out, arrays aren't really what you want here. They make the
>solution more complicated than it needs to be.
Jonathan,
I have read Dale's post quite carefully (which duty I pay to all of his
posts, even if the subject is well above my head), but failed to find any
point of this sort. Instead, I saw a rather masterful treatise on *using*
arrays to achieve the objective. What gives?
Kind regards,
===============
Paul M. Dorfman
Jacksonville, FL
===============
>
>Jonathan Siegel
>
>On Tue, 29 Jul 2003 11:46:03 -0700, Dale McLerran
><stringplayer_2@YAHOO.COM>
>wrote:
>
> >A simple datastep approach that works similarly to Prasad's SQL
> >solution would be as follows:
> >
> >data two;
> > set one(keep=vara rename=(vara=newvar))
> > one(keep=varb rename=(varb=newvar))
> > one(keep=varc rename=(varc=newvar));
> >run;
> >
> >
> >An array based solution would have to load all of the data into
> >memory in a two dimensional array which is indexed on variable
> >and row number. When all data have been read, then loop back
> >through the data by row number within variable index. Thus,
> >we could write the following:
> >
> >data two;
> > set one end=lastrec;
> > array var_in {3} vara varb varc;
> > array all_dat {3,10000} _temporary_;
> >
> > /* Store observed values into _n_th row of all_dat array */
> > do i=1 to 3;
> > all_dat{i,_n_}=var_in{i};
> > end;
> >
> > /* Once we have read all the data, then loop over rows */
> > /* within variable indexes and write the stored value. */
> > if lastrec then do;
> > do i=1 to 3;
> > do j=1 to _n_;
> > newvar = all_dat{i,j};
> > output;
> > end;
> > end;
> > end;
> > keep newvar;
> >run;
> >
> >
> >Hope these help,
> >
> >Dale
_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
|