The UNIVARIATE Procedure

# Example 8: Fitting Density Curves

Procedure features:
PROC UNIVARIATE statement options:
 NOPRINT
HISTOGRAM statement options:
 CBARLINE= CFILL= EXP FILL L= MIDPOINTS= NOPRINT NORMAL
VAR statement
Other features:
 GOPTIONS statement RANNOR function RANEXP function

This example

• creates a sample of 100 observations from a normal distribution and an exponential distribution

• suppresses the tables of descriptive statistics

• creates histograms with superimposed density curves for the normal and exponential distributions

• requests goodness-of-fit tests for a fitted exponential distribution

• specifies the midpoints for histogram intervals

• requests graphical enhancements that change plot colors and line types.

`options nodate pageno=1 linesize=80 pagesize=60;`
 `goptions htitle=4 htext=3 ftext=swissb ftitle=swissb;`
 ```data distrdata; drop n; label Normal_x='Normal Random Variable' Exponential_x='Exponential Random Variable'; do n=1 to 100; Normal_x=10*rannor(53124)+50; Exponential_x=ranexp(18746363); output; end; run; ```
 ```proc univariate data=distrdata noprint; var Normal_x;```
 `histogram Normal_x /normal(noprint) cbarline=grey ;`
 ```title '100 Obs Sampled from a Normal Distribution'; run;```
 ```proc univariate data=distrdata noprint; var Exponential_x;```
 ` histogram /exp(fill l=3) cfill=yellow midpoints=.05 to 5.55 by .25;`
 ```title '100 Obs Sampled from an Exponential Distribution'; run;```

A Histogram Superimposed with Normal Curve

 The output includes parameters estimates for the exponential curve. The exponential parameter threshold parameter is 0 because the THETA= option was omitted. A maximum likelihood estimate is computed for the scale parameter . PROC UNIVARIATE provides three goodness-of-fit tests for the exponential distribution that are based on the empirical distribution function. The p-values for the exponential distribution are larger than the usual cutoff values of 0.05 and 0.10, which indicates not to reject the null hypothesis that the data are exponentially distributed.

A Histogram Superimposed with an Exponential Curve