Hi all,
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?
Thanks,
Saggi
try in a data step (or SQL equivalent)
timestat = intnx('MINUTE2', timestamp, 0, 'END') ;
Richard
Message was edited by: Richard Carson - added missing parameter
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;
Xia Keshan
Hi All,
Thank you for your solutions.
Regards,
Saggi
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...
Thanks,
Udo
Udo,
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?
Thanks again,
Saggi
Saggi -
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...
Thanks,
Udo
Udo,
Thank you - this is very helpful.
Saggi
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.