- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 06-10-2021 08:43 AM
(824 views)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Calling @Rick_SAS
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;