SAS proc timeseries: aggregate at a given interval

I want to use PROC TIMESERIES to aggregate data over a specific interval. Specifically, I want to aggregate over 60 seconds of the window, starting at 30 seconds for a minute.

I've tried with the following code:

proc timeseries data=test out= test_30shift;
id datetime interval=sec60 accumulate=first setmissing=missing align=middle start = '18apr1997.00:05:30'dt end = '19apr1997.00:00:30'dt; 

      

var bid; run away;

I've also tried with ALIGN = BEGINNING.

The result is similar to the following code:

proc timeseries data=test out= test_noshift;
id datetime interval=sec60 accumulate=first setmissing=missing align=beg start = '18apr1997.00:05:00'dt end = '19apr1997.00:00'dt; 
var bid;
run;

      

How do I achieve the aggregation over the interval I want to start from?

+3


source to share


1 answer


You have close. You need to do interval=sec60.31

.

data test;
format dt datetime19.;

do dt = "01JAN2015:00:00:00"dt to "02JAN2015:00:00:00"dt;
    x = rannor(123);
    output;
end;
run;

proc timeseries data=test out=test2;
id dt interval=sec60.31 accumulate=first align=beginning;
var x;
run;

      



enter image description here

The midpoint of 0 - 59 is 29 seconds, so we need to shift 31 seconds to start at MM: 30.

+2


source







All Articles