BookmarkSubscribeRSS Feed
csetzkorn
Lapis Lazuli | Level 10

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

5 REPLIES 5
Reeza
Super User

Do you have SAS/Stat or ETS? 

 

You can check with the following:

 

proc setinit;

run;

csetzkorn
Lapis Lazuli | Level 10
Thanks. Have SAS/Stat but as I said not ets.
Reeza
Super User

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

mkeintz
PROC Star

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;

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

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

 

Register now!

How to Concatenate Values

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.

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
  • 5 replies
  • 991 views
  • 0 likes
  • 4 in conversation