BookmarkSubscribeRSS Feed
Pyrite | Level 9

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
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.
Pyrite | Level 9

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
Not sure about your final dataset, but the CONVERT statement supports a lot of moving windows.

All of the transformations available,

And an example. Here the last one is a moving average and you can specify the window, ie your 30 minutes.


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


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
  • 3 replies
  • 2 in conversation