BookmarkSubscribeRSS Feed
bayoote
Calcite | Level 5

Hi Everyone,

 

I have a data set and I want to get the accumulative 25%,75%, 50% quantiles for several variables. That is, for every row, I want to get the quantiles for the column including all the data before that row. Anyone knows how to do that?

 

Thanks!

 

2 REPLIES 2
ballardw
Super User

You will likely get a better answer if you provide some example data and what the results for that data would be.

Since quantiles are order statistics there are likely to be some questions.

 

I am guessing at this point as to what you mean/ want. Do you have access to SAS/IML? I have a sneaking suspicion that might be needed or the easiest. If you don't know if you have SAS/IML you can try running this code:

 

Proc product_status;

run;

The log will show SAS modules you currently have installed.

RichardDeVen
Barite | Level 11

How many rows does the data have ?

 

Up to a certain point, one simple approach is to combine N groups of sizes 1 to N over the data and process the combined data using PROC MEANS with a BY statement.

 

Example - 100 rows, creates a 'triangle' of grouped data with 5,050 rows ( N (N+1) / 2 ) 

data have;
  call streaminit(123);
  do row = 1 to 100;
    x = ceil(500*rand('normal', 10, 4));
    output;
  end;
run;

data triangle;
  set have nobs=nobs;
  do group = _n_ to nobs;
    output;
  end;
run;

proc sort data=triangle;
  by group;
run;

proc means noprint data=triangle;
  by group;
  var x;
  output out=accum_quartiles q1=q1 p50=p50 q3=q3;
run;
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 895 views
  • 0 likes
  • 3 in conversation