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 (September 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 4 Sep 2008 07:18:27 -0400
Reply-To:   Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Subject:   Re: Getting missing values in Array code
In-Reply-To:   <2ce17c48-b02d-4a7e-b35a-c6c901867452@p31g2000prf.googlegroups.com>
Content-Type:   text/plain; charset=ISO-8859-1

On Thu, Sep 4, 2008 at 5:19 AM, kunal <kunal.krishnan@gmail.com> wrote:

> Hi guys, > > > data piecatg.test; > input obs a b; > cards; > 1 34 45 > 2 65 56 > 3 43 65 > 4 56 56 > 5 89 21 > 6 45 65 > 7 12 34 > 8 44 45 > 9 34 78 > 10 23 23 > ; > run; > > > data piecatg.automated_array_new; > > array x[0:11] _temporary_ ; > array y[0:11] _temporary_ ; > /*input id y{*};*/ > do i=1 to 10 by 1; > set piecatg.test; > y[i] = b; > x{i}= x{i-1}+y{i}; > pred = x{i}; > output; > end; > run; > > > > I am using the above code to generate values in a new column which > should give the following output "pred": > > 45 > 101 > 166 > 222 > 243 > 308 > 342 > 387 > 465 > 488 > > > where "pred" is being calculated as pred{i} = pred{i-1} + b {i} > > for eg: for data > > 45 > 56 > 65 > > o/p window should be > > a b > 45 45 > 56 101 > 65 166 > > where > b{0} = a{0} > b{1} = b{0} + a{1} > b{2} = b{1} + a{2} and so on > > > can any1 please let me know why am i getting missing values in pred > when i run the code?? is there something wrong with the logic?? > > Thanks >

Kunal

It looks that you do not require the use of any array at all.

data test; input obs a b; cards; 1 34 45 2 65 56 3 43 65 4 56 56 5 89 21 6 45 65 7 12 34 8 44 45 9 34 78 10 23 23 ; run;

data need; set test; if _n_ = 1 then pred = b; else pred + b; run;


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