/* voles.sas */ /* -------------------------------------------------------- */ /* ------ vole reproduction example ----------------------- */ /* ---------------------------------------------------------*/ /* ---------------------------------------------------------*/ /* vole reproduction example number of babies distribution */ /* ---------------------------------------------------------*/ /* ---------------------------------------------------------*/ data voles; input number @@; cards; 1 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 10 10 11 ; /* the @@ in the input statement indicates that there is more than one observation on a line. Without this SAS would only read one observation from each line */ /* numerical and graphical summaries */ proc freq data=voles; tables number; title 'vole example number of babies in a litter'; proc univariate data=voles nextrval=5; var number; ods select ExtremeValues BasicMeasures Quantiles; title 'vole example number of babies in a litter distribution'; proc means data=voles maxdec=4 n min q1 median q3 max range qrange mean std; var number; proc means data=voles maxdec=4 p1 p5 p10 p20 p30 p40 p50 p60 p70 p80 p90 p95 p99; var number; run; title; /* graphical summaries histogram, smoothed histogram, and boxplot */ /* -------------------------------------------------------- */ proc sgplot data=voles; title 'voles: number of babies distribution'; histogram number / binwidth=1 binstart=0 datalabel=percent; density number / type=kernel; proc sgplot data=voles; hbox number; run; title; /* title assigns a title for the output --histogram options-- datalabel=percent: display percentage at end of bin use datalabel=count to get frequency --density options-- the type=kernel requests a smooth fit to the data -- run; and title; resets the title */ /* -------------------------------------------------------- */ /* -------------------------------------------------------- */ /* ------ end of vole reproduction example ---------------- */ /* ---------------------------------------------------------*/