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 (May 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 10 May 2009 20:37:55 -0400
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: keep value from previous iteration
Comments: To: Wensui Liu <liuwensui@GMAIL.COM>

Wensui,

Is the following all you are looking for?:

data have; input x; cards; 1 2 3 4 ;

data want; set have; retain last_x; output; last_x=x; run;

Art --------- On Sun, 10 May 2009 20:25:22 -0400, Wensui Liu <liuwensui@GMAIL.COM> wrote:

>Dear All, >I know it is relatively simple but just can't find an elegant and >simple solution with retain statement. >here is what I have. >1 >2 >3 >4 >here is what i want >1 >2 1 >3 2 >4 3 > >I don't want to use lag() function or hash and just want to know a way >in datastep with retain. >thank you so much! >-- >============================== >WenSui Liu >Acquisition Risk, Chase >Blog : statcompute.spaces.live.com > >Tough Times Never Last. But Tough People Do. - Robert Schuller >==============================


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