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 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 4 May 2007 11:21:28 -0400
Reply-To:     Wensui Liu <liuwensui@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Wensui Liu <liuwensui@GMAIL.COM>
Subject:      Re: cumulative product?
Comments: To: celiacai@gmail.com
In-Reply-To:  <1178191211.064832.152770@e65g2000hsc.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

sorry, celiaca, there is small mistake in my previous hash code. following should be correct.

data _null_; if 0 then set test;

dcl hash h (hashexp: 16); h.definekey ('VarA', 'VarB'); h.definedata('VarA', 'VarB', 'product'); h.definedone();

do until (eof); set test end = eof; if h.find() ~= 0 then do; product = 1; end; product = product * VarC; h.replace(); end;

rc = h.output(dataset: 'product'); run;

On 5/3/07, celiacai@gmail.com <celiacai@gmail.com> wrote: > Hi > > I knew there's certain way to calculate subgroup cumulative sum in a > table...but how can I calculate the cumulative product of subgroups > within a dataset? > > Say, the ovservations are sorted by variable A,B and C (namely > subgrouped twice), and I want to find out the product of all Cs within > each B-group. How could I do that? > > celia >

-- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog)


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