## distribution assumption using proc sgplot

Solved
Frequent Contributor
Posts: 130

# distribution assumption using proc sgplot

I am using proc sgplot to plot CDF (series statement) and PDF (density statement) for a dataset.

Does it always require to choose the distribution assumption? e.g., type= normal

Is it possible to plot CDF and PDF witout underline distribution assumption? and if, how to achieve that?

Many thanks!

Accepted Solutions
Solution
‎05-12-2017 08:27 PM
SAS Super FREQ
Posts: 4,277

## Re: distribution assumption using proc sgplot

For continuous distributions, the easiest way is to use PROC UNIVARIATE to create the CDF and PDF plots. The HISTOGRAM statement fits and optionally overlays a nonparamwetric kernel density estimate. The CDFPLOT statement displays the empirical CDF. Here is an example:

``````proc univariate data=sashelp.cars;
var mpg_highway;
histogram mpg_highway / kernel;  /* nonparametric density estimate */
cdfplot mpg_highway;
ods select Histogram CDFPlot;
run;``````

You can also fit and overlay parametric distributions. PROC UNIVARIATE supports about 20 common distributions. Here is an example of fitting lognormal distribution (maximum likelihood estimation) to the same data:

``````proc univariate data=sashelp.cars;
var mpg_highway;
histogram mpg_highway / lognormal;  /* overlay PDF */
cdfplot   mpg_highway / lognormal;  /* overlay CDF */
ods select Histogram CDFPlot;
run;``````

All Replies
PROC Star
Posts: 1,403

## Re: distribution assumption using proc sgplot

Not sure if this is what you're asking, but you can plot densities and distributions in PROC SGPLOT like this

``````data normal;
do x = -3 to 3 by 0.01;
y_pdf = pdf('normal',x);
y_cdf = cdf('normal',x);
output;
end;
run;

title 'Normal Distribution';
proc sgplot data = normal;
band x = x upper = y_pdf lower = 0 / legendlabel = 'Density';
series x = x y = y_cdf / legendlabel = 'CDF';

keylegend / location = inside position = topleft across = 1;
yaxis label = 'Density/Probability';
xaxis label = 'x';
run;
title;``````
Solution
‎05-12-2017 08:27 PM
SAS Super FREQ
Posts: 4,277

## Re: distribution assumption using proc sgplot

For continuous distributions, the easiest way is to use PROC UNIVARIATE to create the CDF and PDF plots. The HISTOGRAM statement fits and optionally overlays a nonparamwetric kernel density estimate. The CDFPLOT statement displays the empirical CDF. Here is an example:

``````proc univariate data=sashelp.cars;
var mpg_highway;
histogram mpg_highway / kernel;  /* nonparametric density estimate */
cdfplot mpg_highway;
ods select Histogram CDFPlot;
run;``````

You can also fit and overlay parametric distributions. PROC UNIVARIATE supports about 20 common distributions. Here is an example of fitting lognormal distribution (maximum likelihood estimation) to the same data:

``````proc univariate data=sashelp.cars;
var mpg_highway;
histogram mpg_highway / lognormal;  /* overlay PDF */
cdfplot   mpg_highway / lognormal;  /* overlay CDF */
ods select Histogram CDFPlot;
run;``````

Frequent Contributor
Posts: 130

## Re: distribution assumption using proc sgplot

Thank you all!

by the way, how can I specify the distribution as t-distribution? without enough observations, I try to avoid normal distribution assumption.

SAS Super FREQ
Posts: 4,277

## Re: distribution assumption using proc sgplot

Typically data are not distributed as t. The t distribution arises as the sampling distribution of statistics. See the article "Why doesn't PROC UNIVARIATE support certain common distributions?"

☑ This topic is solved.