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 (January 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 21 Jan 2008 12:03:36 -0600
Reply-To:     "data _null_," <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_," <datanull@GMAIL.COM>
Subject:      Re: Cummulative sum other subgroup
Comments: To: Muthia Kachirayan <muthia.kachirayan@gmail.com>
In-Reply-To:  <2fc7f3340801210938s53f50fccn705772065dac2e9f@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

using SUM function you can dispense with the IF statement and take advantage of DO UNTIL LAST this capturing the problem rhythm.

cc = sum(cc,ct);

On Jan 21, 2008 11:38 AM, Muthia Kachirayan <muthia.kachirayan@gmail.com> wrote: > Djassy, > > Here is a way. > > data test ; > input an mo de ct; > datalines; > 1 1 1 5 > 1 1 2 7 > 1 1 3 6 > 1 2 1 8 > 1 2 2 3 > 2 1 1 9 > 2 1 2 6 > 2 2 1 4 > ; > run; > proc sort data = test; > by an mo; > run; > > data wanted; > do until(last.mo); > set test; > by an mo; > if first.mo then cc = 0; > cc ++ ct; > output; > end; > run; > > proc print; > run; > > > regards, > > Muthia Kachirayan > > > On Jan 21, 2008 11:57 AM, <djassy@gmail.com> wrote: > > > Is there someone to help me? > > I would like to calculate cc as cumulative sum of ct, group by an, mo, > > de > > > > > > an mo de cc ct > > 1 1 1 5 5 > > 1 1 2 7 12 > > 1 1 3 6 18 > > 1 2 1 8 8 > > 1 2 2 3 11 > > 2 1 1 9 9 > > 2 1 2 6 15 > > 2 2 1 4 4 > > > > data test ; > > input an mo de ct; > > datalines; > > 1 1 1 5 > > 1 1 2 7 > > 1 1 3 6 > > 1 2 1 8 > > 1 2 2 3 > > 2 1 1 9 > > 2 1 2 6 > > 2 2 1 4 > > ; > > proc print; > > run; > > >


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