/* Example of finding summary statistics and graphs using SAS */ /* The data are the gas mileage data from p. 30 on the textbook */ /* The following commands name the data set and variables and list the data */ /* Please read the "Introduction to SAS" on the course web page first */ OPTIONS pagesize=50 linesize=64; DATA gasdata; INPUT mileage; CARDS; 36.3 41 36.9 37.1 44.9 36.8 30 37.2 42.1 36.7 32.7 37.3 41.2 36.6 32.9 36.5 33.2 37.4 37.5 33.6 40.5 36.5 37.6 33.9 40.2 36.4 37.7 37.7 40 34.2 36.2 37.9 36 37.9 35.9 38.2 38.3 35.7 35.6 35.1 38.5 39 35.5 34.8 38.6 39.4 35.3 34.4 38.8 39.7 36.3 36.8 32.5 36.4 40.5 36.6 36.1 38.2 38.4 39.3 41 31.8 37.3 33.1 37 37.6 37 38.7 39 35.8 37 37.2 40.7 37.4 37.1 37.8 35.9 35.6 36.7 34.5 37.1 40.3 36.7 37 33.9 40.1 38 35.2 34.8 39.5 39.9 36.9 32.9 33.8 39.8 34 36.8 35 38.1 36.9 ; /* The following procedure produces several summary statistics and graphs */ /* DATA= tells SAS which data set to use */ /* VAR tells SAS which variable to compute the statistics and graphs for */ /* If there are several variables in the data set */ /* you could specify more than one variable with VAR */ PROC UNIVARIATE DATA=gasdata PLOT FREQ; VAR mileage; TITLE 'Summary of the Gas Mileages for the 100 Cars'; RUN; /* PROC UNIVARIATE gives summary statistics about the variable "mileage" */ /* Look for the mean, median, variance, standard deviation, etc. */ /* The PLOT FREQ command produces a stem-and-leaf display and boxplot */ /* Notice the UNIVARIATE procedure produces rather rudimentary graphs */ /* The INSIGHT procedure will give us the same thing as UNIVARIATE */ /* but with more and nicer-looking graphs. */ /* The syntax is slightly different in INSIGHT: */ PROC INSIGHT; OPEN gasdata; DIST mileage; RUN; /* The graphs INSIGHT produces are a box plot and a histogram.*/ /* To change the class intervals, */ /* click on the arrow at the bottom left of the histogram. Choose "Ticks". */ /* First Tick is the start of the first interval, */ /* Last Tick is the end of the last interval, */ /* and Tick Increment is the interval width. */ /* Note how changing the class intervals changes the look of the histogram. */ /* Note that the histogram shown is a relative frequency histogram. */ /* To get a frequency histogram, while still in PROC INSIGHT, */ /* choose the "Analyze" menu, and choose "Histogram/Bar Chart". */ /* Click on the name of the variable (here, MILEAGE) and then click "Y". */ /* Click "OK" and a frquency histogram should appear. */ /* You can copy and paste the graphs from PROC INSIGHT into Microsoft Word */ /* Click on the border of the box you want, and copy and paste as normal */ /* To quit PROC INSIGHT or remove the INSIGHT graphs, */ /* click the X in the upper right box of the graph(s) */