04-13-2014 02:15 PM
I'm using stock (intraday) transaction data recorded at irregular points in time (e.g., 9:45 ; 9:48 ; 9:49).
I want to convert the data to fix time interval so I can perform some statistical time series analysis, for example the stock price every 2 minutes.
I tried using "proc expand", but didn't find a way to do it. Is this kind of conversion possible using "proc expand" or am I looking in the wrong direction?
I saw some examples with proc timeseries - maybe this is a better way of doing it?
04-14-2014 06:33 AM
Yeah. proc expand can achieve that.
data a; input time : time8. v; format time time8.; cards; 09:45 21 09:48 45 09:49 34 09:54 32 10:02 56 ; run; proc sort data=a; by time;run; data aa; merge a a(firstobs=2 rename=(time=_time)); output; do t=time+60 to coalesce(_time-60,0) by 60; time=t;v=.;output; end; drop t _time; run; proc expand data=aa out=bb method=spline; id time; run;
04-17-2014 04:50 PM
Hello Saggi -
As you mentioned earlier you may want to consider PROC TIMESERIES which analyzes time-stamped transactional data with respect to time and accumulates the data into a time series format as yet another option.
An example can be found here: http://support.sas.com/documentation/cdl/en/etsug/66840/HTML/default/viewer.htm#etsug_timeseries_exa...
04-19-2014 05:51 AM
Thanks you for the reference.
I saw that the example code uses a time interval of a month ("id timestamp interval=month") whereas I want to use a time interval of a second (or millisecond).
I read the proc's syntax but I didn't find any details of the possible frequencies I can use in this option. can you direct me to the relevant documentation?
04-21-2014 09:18 AM
A list of all supported intervals of the TIMESERIES procedure can be found here: http://support.sas.com/documentation/cdl/en/etsug/66840/HTML/default/viewer.htm#etsug_intervals_sect...