DATA Step, Macro, Functions and more

creation and identification of time windows

Reply
Contributor
Posts: 59

creation and identification of time windows

Hello, i have a data, and for every day i want to create time Moving window, and then to process all windows. at the end, i will keep only one row for big window and there will be some statistics of every little windows.

 

moving window includes two big windows(every one is 30 minutes, of course it can be any number) and every one of them include 3 little windows(every one can be different number but total is 30 minutes)

for example my window is 1 hour, so one window is my sample window is 30 minutes, and then the second window  (predicted window) is too 30 minutes. for every window i have to know their id(i have to create id)

what i get  : 

window : 08:00 - 09:00

sample window : 08:00-08:30

                sample_window1 :08:00-08:05, sample_window2 : 08:05-08:15, sample_window3 : 08:5-08:30

predicted window : 08:30-09:00

              predicted_window1 :08:30-08:40, predicted_window2 : 08:40-08:50, predicted_window3 : 08:50-09:00

 

then i have to create interval, for example 10 minutes, and create windows again and so on...

 

window : 08:10 - 09:10

sample window : 08:10-08:40

                sample_window1 :08:10-08:15, sample_window2 : 08:15-08:25, sample_window3 : 08:25-08:40

predicted window : 08:40-09:10

              predicted_window1 :08:40-08:50, predicted_window2 : 08:50-09:00, predicted_window3 : 09:00-09:10

 

off course all times and intervals are macro variables.

 

my data example :

time      date

08:00   26/10/15

08:01   26/10/15

08:10   26/10/15

08:15   26/10/15

08:20   26/10/15

08:29   26/10/15

08:37   26/10/15

08:38   26/10/15

08:47   26/10/15

08:54   26/10/15

08:58  26/10/15

.....

 

How can i do it?  thank you!!!!

Super User
Posts: 17,952

Re: creation and identification of time windows

Do you have SAS/ETS? What statistics are you creating?

Depending on the statistics it may be better to use PROC EXPAND rather than to try and create your windows manually.
Contributor
Posts: 59

Re: creation and identification of time windows

yes, i have ETS. i know about the proc expand, but how i can create in proc expand moving window?

i predicted windows i want only to find the last price and first price, and in the sample window, i want to find some simple statistics, such as mean, total volume... then i want to present it as one row, i.e every big window(in my example 1 hour) .

thank you for your help

Super User
Posts: 17,952

Re: creation and identification of time windows

Not sure about your final dataset, but the CONVERT statement supports a lot of moving windows.

All of the transformations available,
http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/viewer.htm#etsug_expand_sect026...


And an example. Here the last one is a moving average and you can specify the window, ie your 30 minutes.
http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/viewer.htm#etsug_expand_sect034...
Ask a Question
Discussion stats
  • 3 replies
  • 244 views
  • 0 likes
  • 2 in conversation