turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Proc Univariate - Percentiles

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-28-2015 09:54 AM

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.

Can you please help me?

Thank you very much in advance! Vasilis.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Vasilis

04-28-2015 10:01 AM

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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

04-28-2015 10:08 AM

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?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Vasilis

04-29-2015 09:52 AM

Vasilis wrote:

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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

04-29-2015 10:04 AM

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!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Vasilis

04-29-2015 10:54 AM

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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Vasilis

04-29-2015 04:20 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Vasilis

04-29-2015 09:46 AM

Not sure . Did you check PPPlot or QQPlot statement ?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

04-29-2015 09:57 AM

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..