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
- /
- Base SAS Programming
- /
- remove short peaks and troughs in time series

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

05-03-2017 03:24 AM

I only have base sas and wonder and have exhaustive daily values for some time series. Just curious, is there an easy way to remove short peaks and throughs. Here shortness is defined by a parameter n representing the number of days)?

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

05-03-2017 03:51 AM

Do you have SAS/Stat or ETS?

You can check with the following:

proc setinit;

run;

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

05-03-2017 03:39 PM

Thanks. Have SAS/Stat but as I said not ets.

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

05-03-2017 03:59 PM

csetzkorn wrote:

Thanks. Have SAS/Stat but as I said not ets.

Your initial posts say Base SAS, nothing about ETS/IML/STAT modules.

One way remove peaks/throughs is a moving average. Determine your cycle length and then apply a moving average.

For the moving average calculation you can use a temporary array method illustrated

http://support.sas.com/kb/41/380.html

If you have IML, you have more options but it means doing the math yourself that having the ability to use the predesigned procedures.

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

05-03-2017 09:01 AM

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

05-03-2017 09:46 PM - edited 05-03-2017 09:49 PM

Let's say you have daily data sorted by PERMNO (a stock identifier) and DATE. You want 15-day moving averages of PRICE, but will accept window sizes as small as 10-days:

```
%let winsiz=15;
%let minwin=10;
data want;
set have;
by permno;
if first.permno then do;
NDays=0;
sum_price=0;
end;
if NDays<&winsiz then NDays+1;
sum_price + price - ifn(NDays>&winsiz,lag&winsiz(price),0);
if NDays>=&minwin;
mean=sum_price/NDays;
run;
```