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!
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.
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.