BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User

So did you try my code. Just replace proc summary in my code.

data x(drop=month);
input DATE  : ddmmyy12.     MONTH  : monyy5.    VALUE ;
format date date9. month monyy5.;
cards;
01032011      MAR2011    8.50
02032011      MAR2011    8.50
02032011      MAR2011    5.50
02032011      MAR2011    8.50
14032011      MAR2011    7.50
24032011      MAR2011    9.00
24042011      APR2011     8.50
24042011      APR2011     8.50
26042011      APR2011     2.50
24042011      APR2011     3.50
16052011      MAY2011     2.50
24052011      MAY2011     13.50
25052011      MAY2011     4.50
26052011      MAY2011     3.50
27052011      MAY2011     2.50
25062011      JUN2011     10.50
26062011      JUN2011     13.50
27062011      JUN2011     12.50
28062011      JUN2011     13.50
;
run;
data x;
 set x;
 monyy=mdy(month(date),1,year(date));
 format monyy monyy5.;
run;




%macro cal(monyy=);
data xx;
 set x(where=(monyy between intnx('month',&monyy,-&bin+1,'b') and &monyy));
 month=put(&monyy,monyy5.);
run;
proc univariate data=xx noprint;
 class month;
 var value;
 output out=result mean=mean median=median  pctlpts = 10 to 100 by 10 pctlpre = pct_ ; 
run;
%mend cal;


%let bin = 3;

proc sort data=x(keep=monyy) out=temp nodupkey;by monyy;run;
data _null_;
 set temp;
 call execute('%cal(monyy='||strip(monyy)||')');
 if _n_ eq 1 then call execute('data final;set result;stop;run;');
 call execute('proc append base=final data=result force;run;');
run;

Ksharp

Filipvdr
Pyrite | Level 9

Well i did not.. i went on with the code of Keith. If there is no answer within the code of Keith I will have to take yours

Keith
Obsidian | Level 7

My method will not give you the percentiles you need, I stated the limitations of multilabel formats in my original answer.  Ksharp has provided an excellent solution which will work with UNIVARIATE.

Regards,

Keith

Filipvdr
Pyrite | Level 9

Thanks both for your quick reply. I will have a look at Ksharp his code to understand it and implement it.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 18 replies
  • 3979 views
  • 8 likes
  • 4 in conversation