LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (June 2000, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 16 Jun 2000 11:29:42 -0400
Reply-To:   Bob Burnham <Robert.A.Burnham@DARTMOUTH.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Bob Burnham <Robert.A.Burnham@DARTMOUTH.EDU>
Organization:   Dartmouth College, Hanover, NH, USA
Subject:   Re: Product

Hi Mike,

Remember, 'total' isn't a statement, it is the name of a variable. When you are using the '+' operator, SAS is kind enough to automatically retain the variable that you are incrementing. For a product, you have to retain it yourself -- but the end result is not much more complicated:

data test; retain total 1; input x; total = total * x; datalines; 10 20 30 40 ;

proc print; var x total; run ;

OBS X TOTAL

1 10 10 2 20 200 3 30 6000 4 40 240000

"Mike Rayle" <mike.rayle@WRIGHT.EDU> wrote in message news:394A3054.6D83AC22@wright.edu... > Hi, > > I am having trouble computing a running product for a data > set. How do I modify the following code to compute the > product? The sum is easy to do by using the TOTAL > statement. Is there a similar statement for the product? > > data test; > input x; > total+x; > datalines; > 10 > 20 > 30 > 40 > ; > Proc print; > run ; > > Thanks > Mike > Mike.Rayle@Wright.edu


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