turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Computation of backward moving percentiles

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-09-2013 03:08 PM

Hello everybody,

I work with a time series dataset, and I need to compute a backward moving percentile for a time series. How can this be done in SAS? I have considered the EXPAND procedure, but to my knowledge this procedure can only compute a backward moving median (i.e. 50% percentile) using the "MOVMED" statement. How should I proceed if I want to compute a (for example) 20% backward moving percentile using a time window of, say, 250 observations?

Thanks in advance!

Best,

Esben Vibel

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to EsbenVibel

07-09-2013 09:05 PM

How many obs you need to backward moving ?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-10-2013 01:27 AM

My dataset has approx. 10,000 obs., and I would like to compute 20% backward moving percentiles based on a window of 252 observations.

Best,

Esben

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to EsbenVibel

07-10-2013 02:56 AM

I am not familiar with proc expand, maybe you can check the documention and find some one option.

And my code make a window of 252 includes the current obs.

data have(drop=i); do i=1 to 10000; x=ranuni(-1); output; end; run; data want; set have; array a{0:251} _temporary_ ; a{mod(_n_,252)}=x; pct_20=pctl(20,of a{*}); run;

Ksharp

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-10-2013 03:20 AM

When I run the last data step, the log writes the following error message:

ERROR: The ARRAYNAME

The error message refers to the last line (i.e. pct_20=pctl(20,of a{*}). Should this be changed somehow?

Esben

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to EsbenVibel

07-10-2013 03:30 AM

I have no problem. did you lost** _temporary_** ?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-10-2013 03:35 AM

I simply copied your code directly into SAS and ran it. I use SAS 9.1; do I need newer version to run the code?

Esben

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to EsbenVibel

07-10-2013 07:33 AM

Are you still using sas 9.1?

data have(drop=i); do i=1 to 10000; x=ranuni(-1); output; end; run; data want(drop=aa:); set have; array a{0:251} aa1-aa252 ; retain aa: ; a{mod(_n_,252)}=x; pct_20=pctl(20,of a{*}); run;

Ksharp

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-11-2013 05:43 AM

Thanks a lot! It works perfectly.