turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- product of a series in sas?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-02-2009 02:48 PM

Hi,

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

Thanks,

OC

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

Thanks,

OC

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-02-2009 04:25 PM

You'll need to be more specific. What kind of series? What kind of data? Do you have an example?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-02-2009 05:16 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-03-2009 12:23 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-03-2009 12:14 PM

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;

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;