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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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