Calcite | Level 5

## Proc Univariate - Percentiles

nHi everyone. This is my first post. First of all, it is good to be part of this Community!

I have a problem with sas coding. I want to fit a distribution (eg Normal or Lognormal) to some data and take the percentiles. I am using the following code which is fine.

My problem is that i want to extract the P99 of the fitted data at a sas data and not only at the results.

PROC UNIVARIATE DATA = WORK.TEMP1 NOPRINT ;*pctldef=5;

BY RESERVING_LOB_LOCAL;

VAR log_max_incurred;

HISTOGRAM   log_max_incurred /  NOPLOT LOGNORMAL ( W=1  L=1  COLOR=YELLOW  ZETA=EST THETA=0 SIGMA=EST);

OUTPUT OUT=FINAL2 p99=P99 ;

RUN;

By doing this i save at the sas data "final2" only the p99 of the actual data and not of the fitted data too.

Thank you very much in advance! Vasilis.

8 REPLIES 8
Diamond | Level 26

## Re: Proc Univariate - Percentiles

I think you have to use the OUTHIST= option to get that (and it may not be exactly the 99 percentile). You could always take the estimated coefficients of the Lognormal model and compute exactly where the 99 percentile is.

--
Paige Miller
Calcite | Level 5

## Re: Proc Univariate - Percentiles

Thanks, i will try the outhistogram option. However, i would like to get the exact 99 percentile of the fitted data. Can you please give me some more help about yur second proposal? Maybe i don't understand very well but how can i calculate the estimated coefficients?

Diamond | Level 26

## Re: Proc Univariate - Percentiles

```Vasilis wrote:

Thanks, i will try the outhistogram option. However, i would like to get the exact 99 percentile of the fitted data. Can you please give me some more help about yur second proposal? Maybe i don't understand very well but how can i calculate the estimated coefficients?
```

You are specifying a lognormal distribution, and the parameter estimates are calculated by PROC UNIVARIATE, so then you should program the lognormal distribution in a DATA step or otherwise, using these parameters, and find the exact 99%-lie point.

Or as Xia Keshan said, you can read these percentage points from a PPPlot

--
Paige Miller
Calcite | Level 5

## Re: Proc Univariate - Percentiles

In both cases i have to read something first in order to move on. That is not something i want! (I can already read it from the histogram) I want to use the percentile as an input so i need it in sas data form! Thanks!

Diamond | Level 26

## Re: Proc Univariate - Percentiles

I guess I'm not really grasping the problem here.

If you run PROC UNIVARIATE, you can obtain the estimates of the lognormal coefficients. Use ODS OUTPUT PARAMETERESTIMATES=PARAMS; This will give you a SAS data set with the estimates of the Lognormal distribution. From there, you program the distribution using the Lognormal formula, in a SAS data step to determine the 99%-ile point.

As stated in the SAS documentation (click to enlarge so it is readable):

--
Paige Miller
Super User

## Re: Proc Univariate - Percentiles

Welcome to the forums

If you get a table in the results window that you want as a SAS data set you need to find the name using ODS TRACE.

The table name for the quantiles if FITQUANTILES.

Using the SASHELP.CARS dataset I think this is what you want.

ods table fitquantiles=mpg_city_quantiles;

PROC UNIVARIATE DATA = sashelp.cars NOPRINT ;

VAR mpg_city;

HISTOGRAM   mpg_city /  NOPLOT LOGNORMAL ( W=1  L=1  COLOR=YELLOW  ZETA=EST THETA=0 SIGMA=EST);

RUN;

proc print data=mpg_city_quantiles;

run;

A blog post on the topic:

How do I get my SAS results into a data set? | Statistics and other stuff from a geek

Super User

## Re: Proc Univariate - Percentiles

Not sure . Did you check PPPlot or QQPlot statement ?

Calcite | Level 5

## Re: Proc Univariate - Percentiles

I need the quantiles of the fitted data...so first i have to fit the data to the distribution i am interested in and then extract the quantiles at a sas data. With the code that you can see above i can do all of this except the part of extraction to a sas data. Is there a another way to fit some data to a distribution? I only know this method with the histogram inside a proc univariate..

Discussion stats
• 8 replies
• 1681 views
• 0 likes
• 4 in conversation