|
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
|