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 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 14 Dec 2009 08:28:27 -0600
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: SAS dynamic arrays
Comments: To: HÃ¥kan Lane <hlane@cls.dk>
In-Reply-To:  <20091214133122.10436wcl9ieigpp6@webmail.nfit.au.dk>
Content-Type: text/plain; charset=ISO-8859-1

No reason you would need to dimension it at all. SAS is quite smart and can figure it out for you on the fly.

array sampled sampled:; will take every variable starting with 'sampled' and something after it.

-Joe

On Mon, Dec 14, 2009 at 6:31 AM, HÃ¥kan Lane <hlane@cls.dk> wrote:

> I would like to implement an array the size of which is not known a > priori. Instead of declaring an implicit value for the number of > elements, I wish to find this value from a variable. This can be done > in other languages including Fortran. > > My attempt to code this as shown below fails. > > DATA libout.pdata; > SET cpr; > byear=aar-alder; > numyears=&slutaar-&startaar+1; > Array sampled{numyears} sampled&startaar - sampled&slutaar; > sampled{aar}=1; > DROP alder numyears; > IF last.pnr THEN output; > ELSE DO; > END; > RUN; > > The idea is to replace a structure with one record every year that a > person was in our records with their age so an array with a 1 if they > were in and 0 if they weren't. The age (alder from above) is > represented with a birthyear. This would quite obviously save a lot of > redundant data. The issue is that we might run the program with > different start and end years. That is why it would be better for them > to be external constants. > > Thanks in advance. > > Regards, > > Håkan Lane >


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