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)?
05-03-2017 03:59 PM
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
If you have IML, you have more options but it means doing the math yourself that having the ability to use the predesigned procedures.
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;