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.
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.
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?
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
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!
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):
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
Not sure . Did you check PPPlot or QQPlot statement ?
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..
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.