BookmarkSubscribeRSS Feed
Hi,

Does anyone happen to know how to find a product of a series in sas?

Thanks,
OC
4 REPLIES 4
Doc_Duke
Rhodochrosite | Level 12
You'll need to be more specific. What kind of series? What kind of data? Do you have an example?
I have multiple observations of different event ranges and I would like to multiply variables in each event range conditional on the given observation [similar to using PROC MEANS and summing a variable] but instead of summing, I would like to multiply the variable.
deleted_user
Not applicable
An indirect approach for non-zero numbers is the log transformation. Use PROC MEANS for sum(log(|x|)) and sum(x<0), then prod(x) = (-1)^sum(x<0) * e^sum(log(|x|)).
Doc_Duke
Rhodochrosite | Level 12
The direct approach is to use the RETAIN statement, with the BY statement to designate the groupings. See

http://support.sas.com/documentation/cdl/en/lrdict/59540/HTML/default/a000214163.htm

for an example of using RETAIN. Something like

DATA rawdata;
INPUT group value;
DATALINES;
1 1
1 2
1 3
2 4
2 5
2 6
;
RUN;

DATA products;
SET rawdata;
BY group;
RETAIN Prod;
IF first.group THEN prod=1;
prod=prod*value;
IF last.group THEN OUTPUT;
run;
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1370 views
  • 0 likes
  • 3 in conversation