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)?
Do you have SAS/Stat or ETS?
You can check with the following:
proc setinit;
run;
@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.
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.