0% found this document useful (0 votes)
2 views

stat 440 lab exercises 15

The document outlines lab exercises for Statistics 440, focusing on using SAS for data analysis. Key tasks include creating frequency reports using PROC FREQ, validating data, generating summary statistics with PROC MEANS, and exporting reports to HTML. The exercises emphasize understanding data distributions and correcting data entry errors.

Uploaded by

newtondr7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

stat 440 lab exercises 15

The document outlines lab exercises for Statistics 440, focusing on using SAS for data analysis. Key tasks include creating frequency reports using PROC FREQ, validating data, generating summary statistics with PROC MEANS, and exporting reports to HTML. The exercises emphasize understanding data distributions and correcting data entry errors.

Uploaded by

newtondr7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Statistics 440: Lab Exercises 15

Before you begin:


Login to Illinois Compass (compass.uiuc.edu) and download the SAS data sets from the
Data\Lab 15 folder. Save them in ‘D:\netid’. Create the libref ‘st’ which points to ‘D:\netid’ (or
folder of your choice). When you reference the SAS data sets, use the library ‘st’.
1. Creating Frequency Reports
a. Use PROC FREQ to create a report using the st.sanfran data set that displays the
frequency count for each DepartDay. Add an appropriate title.

SAS Output
Flights from San Francisco by Day of Week

The FREQ Procedure

Cumulative Cumulative
DepartDay Frequency Percent Frequency Percent
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
1 6 11.54 6 11.54
2 13 25.00 19 36.54
3 5 9.62 24 46.15
4 7 13.46 31 59.62
5 7 13.46 38 73.08
6 8 15.38 46 88.46
7 6 11.54 52 100.00

b. Use PROC FREQ to create a report using the st.sanfran data set that displays the
frequency count for each Destination. Add an appropriate title.

SAS Output
Flights from San Francisco

The FREQ Procedure

Cumulative Cumulative
Destination Frequency Percent Frequency Percent
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
ANC 10 19.23 10 19.23
HND 8 15.38 18 34.62
HNL 3 5.77 21 40.38
RDU 6 11.54 27 51.92
SEA 25 48.08 52 100.00

c. You can specify many options in the TABLES statement to control the calculations and
appearance of a frequency table. The NOCUM option suppresses the printing of the
cumulative frequencies and cumulative percentages. You can specify options in a
TABLES statement in the following way:
tables variable / options;
Recall your program from Exercise 1.b and add the NOCUM option to the TABLES
statement.
Statistics 440: Lab Exercises 15

SAS Output
Flights from San Francisco

The FREQ Procedure

Destination Frequency Percent


ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
ANC 10 19.23
HND 8 15.38
HNL 3 5.77
RDU 6 11.54
SEA 25 48.08

d. Use PROC FREQ to create a report using the st.sanfran data set that displays the
frequency count for each Destination by DepartDay. Remove the title after this
report since it doesn’t apply to the next exercise.
Partial SAS Output
Flights from San Francisco

The FREQ Procedure

Table of Destination by DepartDay

Destination
DepartDay

Frequency‚
Percent ‚
Row Pct ‚
Col Pct ‚ 1‚ 2‚ 3‚ 4‚ Total
ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ
ANC ‚ 0 ‚ 3 ‚ 1 ‚ 1 ‚ 10
‚ 0.00 ‚ 5.77 ‚ 1.92 ‚ 1.92 ‚ 19.23
‚ 0.00 ‚ 30.00 ‚ 10.00 ‚ 10.00 ‚
‚ 0.00 ‚ 23.08 ‚ 20.00 ‚ 14.29 ‚
ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ
HND ‚ 1 ‚ 2 ‚ 1 ‚ 3 ‚ 8
‚ 1.92 ‚ 3.85 ‚ 1.92 ‚ 5.77 ‚ 15.38
‚ 12.50 ‚ 25.00 ‚ 12.50 ‚ 37.50 ‚
‚ 16.67 ‚ 15.38 ‚ 20.00 ‚ 42.86 ‚
ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ
HNL ‚ 0 ‚ 0 ‚ 0 ‚ 0 ‚ 3
‚ 0.00 ‚ 0.00 ‚ 0.00 ‚ 0.00 ‚ 5.77
‚ 0.00 ‚ 0.00 ‚ 0.00 ‚ 0.00 ‚
‚ 0.00 ‚ 0.00 ‚ 0.00 ‚ 0.00 ‚
ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ
RDU ‚ 2 ‚ 1 ‚ 1 ‚ 0 ‚ 6
‚ 3.85 ‚ 1.92 ‚ 1.92 ‚ 0.00 ‚ 11.54
‚ 33.33 ‚ 16.67 ‚ 16.67 ‚ 0.00 ‚
‚ 33.33 ‚ 7.69 ‚ 20.00 ‚ 0.00 ‚
ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ
Statistics 440: Lab Exercises 15

2. Validating Data with PROC FREQ


a. PROC FREQ is useful in checking the validity and completeness of data. Use PROC
FREQ to check the validity of the variables Gender and JobCode in the
st.mechanics data set. What do you notice about the values of the variable
Gender? What do you notice about the values of the variable JobCode?
SAS Output
The FREQ Procedure

Cumulative Cumulative
Gender Frequency Percent Frequency Percent
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
B 1 2.94 1 2.94
F 17 50.00 18 52.94
G 1 2.94 19 55.88
M 15 44.12 34 100.00

Job Cumulative Cumulative


Code Frequency Percent Frequency Percent
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
MECH01 6 18.18 6 18.18
MECH02 12 36.36 18 54.55
MECH03 15 45.45 33 100.00

Frequency Missing = 1

b. Assume that the values ‘B’ and ‘G’ in Gender were errors made in data-entry and were
meant to be ‘M’ and ‘F’ respectively. Correct these values in the st.mechanics data
set. Rerun the frequency reports from part a. to check whether the changes have been
made.

3. Creating Basic Summary Reports


a. Generate a PROC MEANS report using the st.sanfran data set as input to display
statistics for the variables CargoRev and TotPassCap only. Remove any titles
currently in effect.
SAS Output
The MEANS Procedure

Variable N Mean Std Dev Minimum Maximum


ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
CargoRev 52 33433.50 23731.72 9417.00 84495.00
TotPassCap 52 203.8076923 52.4494298 150.0000000 267.0000000
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
Statistics 440: Lab Exercises 15

b. Modify the previous report to display the data for each Destination. Limit the
number of decimal places in the output to two. The output shown below is only partial
output; all statistics should display in your report.
Partial SAS Output
The MEANS Procedure

N
Destination Obs Variable N Mean Std Dev
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
ANC 10 CargoRev 10 35811.30 4458.74
TotPassCap 10 257.60 11.69

HND 8 CargoRev 8 78625.50 3251.06


TotPassCap 8 250.50 8.33

HNL 3 CargoRev 3 59684.00 3464.64


TotPassCap 3 207.00 0.00

RDU 6 CargoRev 6 37840.00 4787.04


TotPassCap 6 267.00 0.00

SEA 25CargoRev 25 13813.32 2316.59


TotPassCap 25 151.80 4.97
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

4. Requesting Specific Statistics through PROC MEANS


Modify the report from Exercise 3, and alter the PROC MEANS statement to request only the
minimum (MIN), maximum (MAX), and mean (MEAN) statistics.
SAS Output
The MEANS Procedure

N
Destination Obs Variable Minimum Maximum Mean
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
ANC 10 CargoRev 31992.00 44643.00 35811.30
TotPassCap 238.00 267.00 257.60

HND 8 CargoRev 73143.00 84495.00 78625.50


TotPassCap 237.00 255.00 250.50

HNL 3 CargoRev 55728.00 62178.00 59684.00


TotPassCap 207.00 207.00 207.00

RDU 6 CargoRev 31734.00 43344.00 37840.00


TotPassCap 267.00 267.00 267.00

SEA 25 CargoRev 9417.00 17931.00 13813.32


TotPassCap 150.00 165.00 151.80
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

5. Sending a Report to an HTML File


Generate a PROC UNIVARIATE report using the st.sanfran data set as input to display
statistics for the variable TotPassCap only. Output the report to an HTML file. What
Statistics 440: Lab Exercises 15

additional information do you get from PROC UNIVARIATE that you do not get from PROC
MEANS?

Portions Copyright  2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.
Reproduced with permission of SAS Institute Inc., Cary, NC, USA. SAS Institute Inc. makes no
warranties with respect to these materials and disclaims all liabilities thereof.
Statistics 440: Lab Exercises 15

You might also like