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 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 24 Sep 2010 10:55:34 -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: Using retain
Comments: To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>

Gerhard,

I'll stick with my suggested code. If you look carefully at the OP's desired result, and the result obtained from the OP's original code, they differ the second time that type switches back to "A".

Art -------- On Fri, 24 Sep 2010 10:46:18 -0400, Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE> wrote:

>I've run your code and the result is exactly what you inserted after > >Want: > > >Where is your problem? Did you want something different? > >Gerhard > > > > >On Fri, 24 Sep 2010 10:36:59 -0400, Sas Quest <sasquest@GMAIL.COM> wrote: > >>data have; >>input sub type$ val; >>cards; >>1 A 20 >>1 A 30 >>1 A 36 >>1 A 41 >>1 B 1 >>1 B 5 >>1 B 11 >>1 B 19 >>2 A 12 >>2 A 20 >>2 A 29 >>2 A 31 >>2 B 3 >>2 B 10 >>2 B 11 >>run; >> >>Want: >>Sub type val n_val >>1 A 20 20 >>1 A 30 30 >>1 A 36 36 >>1 A 41 41 >>1 B 1 42 >>1 B 5 46 >>1 B 11 52 >>1 B 19 60 >>2 A 12 12 >>2 A 20 20 >>2 A 29 29 >>2 A 31 31 >>2 B 3 34 >>2 B 10 41 >>2 B 11 42 >> >>my code: >> >>data want; >>set have; >>by sub type; >>retain val_ 0; >>n_val=val_+val; >>/*f=first.type; >>l=last.type;*/ >>if last.type then val_=val; >>drop val_; >>run; >> >> >>What can be modified in my code to get the desired output? >> >>Thanks


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