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:         Thu, 3 May 2007 06:41:00 -0500
Reply-To:     "Huang, JS" <Huang.JS@PRINCIPAL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Huang, JS" <Huang.JS@PRINCIPAL.COM>
Subject:      Re: cumulative product?
Comments: To: celiacai@GMAIL.COM
In-Reply-To:  A<1178191211.064832.152770@e65g2000hsc.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"

Celia:

See if this is what you are looking for. If not, write back for more details.

data Test; input VarA $ VarB $ VarC; datalines; a A 3 a A 4 a A 5 a B 4 a B 5 a B 6 a B 7 a C 5 a D 6 a D 7 b A 4 b A 5 b A 6 b B 5 b B 6 b B 7 b B 8 b C 6 b D 7 b D 8 ;

proc sort data=Test; by VarA VarB; run;

data Result; retain CumuProduct; set Test; by VarA VarB; if first.VarB then do; CumuProduct=1; end; CumuProduct=CumuProduct*VarC; run;

proc print data=Result; var VarA VarB VarC CumuProduct; run;

***** Output ***** The SAS System 06:22 Thursday, May 3, 2007 3

Cumu Obs VarA VarB VarC Product

1 a A 3 3 2 a A 4 12 3 a A 5 60 4 a B 4 4 5 a B 5 20 6 a B 6 120 7 a B 7 840 8 a C 5 5 9 a D 6 6 10 a D 7 42 11 b A 4 4 12 b A 5 20 13 b A 6 120 14 b B 5 5 15 b B 6 30 16 b B 7 210 17 b B 8 1680 18 b C 6 6 19 b D 7 7 20 b D 8 56

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of celiacai@GMAIL.COM Sent: Thursday, May 03, 2007 6:20 AM To: SAS-L@LISTSERV.UGA.EDU Subject: cumulative product?

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

-----Message Disclaimer-----

This e-mail message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended recipient, any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by reply email to Connect@principal.com and delete or destroy all copies of the original message and attachments thereto. Email sent to or from the Principal Financial Group or any of its member companies may be retained as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature for purposes of the Uniform Electronic Transactions Act (UETA) or the Electronic Signatures in Global and National Commerce Act ("E-Sign") unless a specific statement to the contrary is included in this message.

While this communication may be used to promote or market a transaction or an idea that is discussed in the publication, it is intended to provide general information about the subject matter covered and is provided with the understanding that The Principal is not rendering legal, accounting, or tax advice. It is not a marketed opinion and may not be used to avoid penalties under the Internal Revenue Code. You should consult with appropriate counsel or other advisors on all matters pertaining to legal, tax, or accounting obligations and requirements.


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