BookmarkSubscribeRSS Feed
Mverniquet
Calcite | Level 5

I would like to estimate the kernel percentiles from PROC KDE with this code:

 

proc kde data=data_ajust;
univar x_0 / percentiles  METHOD=SJPI;
ods output percentiles=P1CDF;
run;

But with this code I get the empirical percentiles and not the kernel percentiles.

 

With the following code I can obtain the kernel estimated density, and I can calculate the percentiles with the area under the curve.

 

proc kde data=data_ajust;
univar x_0 / percentiles  METHOD=SJPI out=density;
run;


I would like to know if it's possible to get the kernel percentiles directly from the PROC KDE or with another method.

 

 

2 REPLIES 2
Rick_SAS
SAS Super FREQ

Sure, use the CDF option to get the cumulative density estimate. The 100*p_th percentile is the smallest value such that the CDF is greater than or equal to p.

 

There are various ways to get a list of percentiles from the CDF. Here is one way:

 

/* sample data */
data heart;
set sashelp.heart; where sex="Female";
run;
/* use the CDF option, which creates the 'Distribution' variable */
proc kde data=heart;
univar cholesterol / CDF  METHOD=SJPI out=density;
run;

/* The 100*p_th percentile is the smallest data value for which the CDF exceeds p */
data Pctls;
array MyPctls[8] _temporary_ (0.05 0.1 0.25 0.5 0.75 0.9 0.95 1.0);  /* end array with 1.0 */
retain k 1;
set density;
Pctl = MyPctls[k];
if distribution >= Pctl then do;
   output;
   k + 1;
end;
drop k;
run;

proc print data=Pctls;
var PCtl Var Value Distribution;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 662 views
  • 2 likes
  • 3 in conversation