step by step basic statistics using sas exercises

33

Upload: hernando-hernandez-david

Post on 08-Sep-2015

38 views

Category:

Documents


3 download

DESCRIPTION

Excellent book for reading statistics. This explore the use of SAS in statistics in rigorous form. It is wonderful for beginners.

TRANSCRIPT

  • Praise for Larry Hatcher

    The problems are interesting, and the tasks required are those a researcher must undertake. Students who work through all of the exercises in this book will definitely be confident and prepared to use SAS to conduct these analyses independently.

    Sheri Bauman, Ph.D. Assistant Professor

    Department of Educational Psychology University of Arizona, Tucson

    My graduate students and I have had a good chance to look over the new workbook...The general consensus is that it is extremely successful on a number of levels. [Larry Hatcher has] thought of everything...We especially like how [he] incorporated additional explanations to help students navigate the computer itself.

    Frank Pajares

    Winship Distinguished Research Professor Emory University

  • BASICSTATISTICS

    Using SASL A R R Y H A T C H E R , P H . D .

    E X E R C I S E SStep-by-Step

  • The correct bibliographic citation for this manual is as follows: Hatcher, Larry. 2003. Step-by-Step Basic Statistics Using SAS: Exercises, Cary, NC: SAS Institute Inc.

    Step-by-Step Basic Statistics Using SAS: Exercises

    Copyright 2003 by SAS Institute Inc., Cary, NC, USA.

    ISBN 1-59047-149-0

    All rights reserved. Printed in the United States of America. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute Inc.

    U.S. Government Restricted Rights Notice: Use, duplication, or disclosure of this software and related documentation by the U.S. government is subject to the Agreement with SAS Institute and the restrictions set forth in FAR 52.227-19, Commercial Computer Software-Restricted Rights (June 1987). SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.

    1st printing, April 2003

    Note that text corrections may have been made at each printing.

    SAS Publishing provides a complete selection of books and electronic products to help customers use SAS software to its fullest potential. For more information about our e-books, e-learning products, CDs, and hard- copy books, visit the SAS Publishing Web site at support.sas.com/pubs or call 1-800-727-3228.

    SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration.

    Other brand and product names are trademarks of their respective companies.

  • Contents

    Acknowledgments.......................................................................... ix Exercises for Chapter 3: Writing and Submitting

    SAS Programs .......................................................................... 3 Exercise 3.1: Computing Mean Height, Weight, and Age......... 3 Exercise 3.2: Computing Mean Age, IQ, and Income............... 6

    Exercises for Chapter 4: Data Input ........................................... 9 Exercise 4.1: Creating and Analyzing a Data Set

    Containing LAT Test Scores ................................................. 9 Exercise 4.2: Creating and Analyzing a Data Set

    Containing Information About Volunteerism........................ 14 Exercises for Chapter 5: Creating Frequency Tables............. 21

    Exercise 5.1: Using PROC FREQ to Analyze LAT Data......... 21 Exercise 5.2: Using PROC FREQ to Analyze Exercise

    Data .................................................................................... 27 Exercises for Chapter 6: Creating Graphs............................... 33

    Exercise 6.1: Using PROC CHART to Create Bar Charts from LAT Data ......................................................... 33

    Exercise 6.2: Using PROC CHART to Create Bar Charts from an Experiment About Goal Setting .................. 38

    Exercises for Chapter 7: Measures of Central Tendency and Variability......................................................................... 47 Exercise 7.1: Using PROC UNIVARIATE to Identify

    Normal, Skewed, and Bimodal Distributions ....................... 47 Exercise 7.2: Using PROC UNIVARIATE and PROC

    MEANS to Compute Measures of Variability ...................... 56

  • iv Contents

    Exercises for Chapter 8: Creating and Modifying Variables and Data Sets......................................................... 63Exercise 8.1: Working with an Academic Development

    Questionnaire ..................................................................... 63Exercise 8.2: Using Subsetting IF Statements with the

    Academic Development Data ............................................. 70Exercises for Chapter 9: z Scores ............................................ 77

    Exercise 9.1: Satisfaction with Academic Development and the Social Environment Among College Students........ 77

    Exercise 9.2: Physical Fitness and Verbal Ability .................. 84 Exercises for Chapter 10: Bivariate Correlation....................... 91

    Exercise 10.1: Correlational Study of Drinking and Driving Behavior.................................................................. 91

    Exercise 10.2: Correlational Study of Nurses Intent to Remain ............................................................................. 100

    Exercises for Chapter 11: Bivariate Regression..................... 107 Exercise 11.1: Predicting Current Drinking and Driving

    Behavior from Previous Behavior...................................... 107Exercise 11.2: Predicting Nurses Intent to Remain from

    Emotional Exhaustion ....................................................... 115 Exercises for Chapter 12: Single-Sample t Test .......................123

    Exercise 12.1: Answering SAT Reading Comprehension Questions Without the Passages....................................... 123

    Exercise 12.2: Predicting the Results of Coin Flips .............. 129Exercises for Chapter 13: Independent-Samples t Test .......... 135

    Exercise 13.1: Sex Differences in Sexual Jealousy.............. 135Exercise 13.2: Effect of Interviewer Suspicion on

    Interviewee Nervousness.................................................. 142Exercises for Chapter 14: Paired-Samples t Test .................... 151

    Exercise 14.1: Perceived Problem Seriousness as a Function of Time of Day.................................................... 151

    Exercise 14.2: Effect of Functional Family Therapy on Probation Compliance for Juvenile Delinquents ............... 159

  • Contents v

    Exercises for Chapter 15: One-Way ANOVA with One Between-Subjects Factor..........................................................167Exercise 15.1: The Effect of Misleading Suggestions on

    the Creation of False Memories........................................ 167Exercise 15.2: The Effect of News Source Credibility on

    Voter Reactions to Political Scandal ................................. 177 Exercises for Chapter 16: Factorial ANOVA with Two

    Between-Subjects Factors ................................................... 187Exercise 16.1: The Effects of Misleading Suggestions

    and Pre-Event Instructions on the Creation of False Memories ................................................................ 187

    Exercise 16.2: The Effect of News Source Credibility and Nature of the Scandal on Voter Reactions to Political Scandal................................................................ 198

    Exercises for Chapter 17: Chi-Square Test of Independence ....................................................................... 209Exercise 17.1: The Relationship Between Sex of

    Children and Marital Disruption......................................... 209 Exercise 17.2: The Relationship Between Membership

    in College Student Organizations and Sexually Coercive Behavior in Men................................................. 218

    Solution for Chapter 3: Writing and Submitting SAS Programs ...................................................................... 229 Solution to Exercise 3.1: Computing Mean Height,

    Weight, and Age ............................................................... 229Solution for Chapter 4: Data Input...........................................233

    Solution to Exercise 4.1: Creating a Data Set Containing LAT Test Scores ............................................................... 233

    Solution for Chapter 5: Creating Frequency Tables ............. 237Solution to Exercise 5.1: Using PROC FREQ to Analyze

    LAT Data........................................................................... 237

  • vi Contents

    Solution for Chapter 6: Creating Graphs ............................... 241 Solution to Exercise 6.1: Using PROC CHART to Create

    Bar Charts from LAT Data ................................................ 241Solution for Chapter 7: Measures of Central Tendency and

    Variability............................................................................... 247Solution to Exercise 7.1: Using PROC UNIVARIATE to

    Identify Normal, Skewed, and Bimodal Distributions......... 247Solution for Chapter 8: Creating and Modifying Variables

    and Data Sets ....................................................................... 259Solution to Exercise 8.1: Working with an Academic

    Development Questionnaire ............................................. 259Solution for Chapter 9: z Scores ............................................265

    Solution to Exercise 9.1: Satisfaction with Academic Development and the Social Environment Among College Students............................................................... 265

    Solution for Chapter 10: Bivariate Correlation...................... 271Solution to Exercise 10.1: Correlational Study of Drinking

    and Driving Behavior......................................................... 271Solution for Chapter 11: Bivariate Regression...................... 277

    Solution to Exercise 11.1: Predicting Current Drinking and Driving Behavior from Previous Behavior ......................... 277

    Solution for Chapter 12: Single-Sample t Test ...................... 285Solution to Exercise 12.1: Answering SAT Reading

    Comprehension Questions Without the Passages............ 285Solution for Chapter 13: Independent-Samples t Test ......... 289

    Solution to Exercise 13.1: Sex Differences in Sexual Jealousy............................................................................ 289

    Solution for Chapter 14: Paired-Samples t Test.................... 295Solution to Exercise 14.1: Perceived Problem

    Seriousness as a Function of Time of Day ....................... 295

  • Contents vii

    Solution for Chapter 15: One-Way ANOVA with One Between-Subjects Factor .................................................... 301 Solution to Exercise 15.1: The Effect of Misleading

    Suggestions on the Creation of False Memories .............. 301Solution for Chapter 16: Factorial ANOVA with Two

    Between-Subjects Factors .................................................. 311Exercise 16.1: The Effects of Misleading Suggestions

    and Pre-Event Instructions on the Creation of False Memories ................................................................ 311

    Solution for Chapter 17: Chi-Square Test of Independence ....................................................................... 321Solution to Exercise 17.1: The Relationship Between

    Sex of Children and Marital Disruption.............................. 321Index ......................................................................................... 327

  • viii Contents

  • Acknowledgments

    During the development of these books, Caroline Brickley, Gretchen Rorie Harwood, Stephenie Joyner, Sue Kocher, Patsy Poole, and Hanna Schoenrock served as editors. All were positive, supportive, and helpful. They made the books stronger, and I thank them for their guidance.

    A number of other people at SAS made valuable contributions in a variety of areas. My sincere thanks go to those who reviewed the books for technical accuracy and readability: Jim Ashton, Jim Ford, Marty Hultgren, Catherine Lumsden, Elizabeth Maldonado, Paul Marovich, Ted Meleky, Annette Sanders, Kevin Scott, Ron Statt, and Morris Vaughan. I also thank Candy Farrell and Karen Perkins for production and design; Joan Stout for indexing; Cindy Puryear and Patricia Spain for marketing; and Cate Parrish for the cover designs.

    Special thanks to my wife Ellen, who was loving and supportive throughout.

    .

  • x Step-by-Step Basic Statistics Using SAS: Exercises

  • Overview

    This section contains two exercises for each chapter, beginning with Chapter 3, Writing and Submitting SAS Programs. Each exercise includes an overviewthat describes the purpose of the exercise, a detailed description of the assignment, a list of the items to be handed in, and hints on completing the assignment.

  • 2 Step-by-Step Basic Statistics Using SAS: Exercises

  • Exercises for Chapter 3 3

    Exercises for Chapter 3: Writing and SubmittingSAS Programs

    Exercise 3.1: Computing Mean Height, Weight, and Age

    Overview

    In this exercise, you will use the SAS windowing environment to write and submit a simple SAS program. You will print the SAS program, along with the resulting SAS log and SAS output files.

    Your Assignment

    1. First, you should be sure that all of your windows are clear (that is, you do not have a program in the Editor window, and you do not have output in the Log or Output windows). If you have just opened SAS, all of your windows should be clear. However, if you have already created and submitted SAS programs during this session, then you will have to clear your windows. If this is the case, then select the following (Remember that the Window menu might contain the name that you gave to your SAS program, rather than the word EDITOR, which appears here.):

    Window Editor Edit Clear All Window Log Edit Clear All Window Output Edit Clear All

  • 4 Step-by-Step Basic Statistics Using SAS: Exercises

    All three of your windows should now be clear. If it is not already, make sure that the Editor window is the active window. Select the following:

    Window Editor 2. Use the Editor window to write the following program (see the notes

    following the program before you begin): 1 OPTIONS LS=80 PS=60; 2 DATA D1; 3 INPUT SUB_NUM 4 HEIGHT 5 WEIGHT 6 AGE ; 7 DATALINES; 8 1 64 140 20 9 2 68 170 28 10 3 74 210 20 11 4 60 110 32 12 5 64 130 22 13 6 68 170 23 14 7 65 140 22 15 8 65 140 22 16 9 68 160 22 17 ; 18 PROC MEANS DATA=D1; 19 VAR HEIGHT WEIGHT AGE; 20 TITLE1 'type your name here'; 21 RUN;

    Some notes regarding this program:

    Do not type the line numbers that appear on the left (i.e., 1, 2, 3, and so on); these line numbers are provided simply for you to use as a guide.

    On line 3 in the INPUT statement, the first variable name is SUB_NUM. Be sure to type this variable name using an underscore (_) and not a hyphen (-).

    On line 20 in the TITLE1 statement, be sure to type your first and last name enclosed in single quotation marks.

    Dont worry if you dont understand the data that are contained in this program or the analysis that it performs. You are only working with this

  • Exercises for Chapter 3 5

    program at this time in order to gain experience with using the SAS windowing environment.

    3. Submit the program, and, if necessary, correct it so that it runs without errors.

    4. Review your log and output windows for possible errors.

    5. When you are sure that your program ran correctly without errors, print your SAS program, SAS log, and SAS output.

    What You Will Hand In

    Hand in the following materials stapled together in this order:

    1. A printout of your SAS program. At the top of this printout, write Exercise 3.1 and your first and last names.

    2. A printout of your SAS log.

    3. A printout of your SAS output. Your SAS output must have your name on it in the title position in order to receive full credit. If you typed your name in the TITLE1 statement of your SAS program correctly, it should appear in the title position on the output.

    Hint

    If your program ran correctly, your output should resemble the following output (except that your name will appear where JANE DOE now appears):

    JANE DOE 1 The MEANS Procedure

    Variable N Mean Std Dev Minimum Maximum -----------------------------------------------------------------

    HEIGHT 9 66.2222222 3.8980052 60.0000000 74.0000000 WEIGHT 9 152.2222222 29.0593263 110.0000000 210.0000000 AGE 9 23.4444444 3.9721251 20.0000000 32.0000000 -----------------------------------------------------------------

  • 6 Step-by-Step Basic Statistics Using SAS: Exercises

    Exercise 3.2: Computing Mean Age, IQ, and Income

    Overview

    In this exercise, you will again use the SAS windowing environment to write and submit a simple SAS program. You will print the SAS program, along with the resulting SAS log and SAS output files.

    Your Assignment

    1. First, you should be sure that all of your windows are clear (that is, you do not have a program in the Editor window, and you do not have output in the Log or Output windows). If you have just opened SAS, all of your windows should be clear. However, if you have already created and submitted SAS programs during this session, then you will have to clear your windows. If this is the case, then select the following (Remember that the Window menu might contain the name that you gave to your SAS program, rather than the word EDITOR, which appears here.):

    Window Editor Edit Clear All Window Log Edit Clear All Window Output Edit Clear All

    All three of your windows should now be clear. If it is not already, make sure that the Editor window is the active window. Select the following:

    Window Editor

  • Exercises for Chapter 3 7

    2. Use the Editor window to write the following program (see the notes following the program before you begin): 1 OPTIONS LS=80 PS=60; 2 DATA D1; 3 INPUT AGE 4 IQ 5 INCOME; 6 DATALINES; 7 36 110 25000 8 28 105 29000 9 55 99 58000 10 44 102 45000 11 46 108 51000 12 39 90 46000 13 29 100 31000 14 40 92 43000 15 32 105 31000 16 ; 17 PROC MEANS DATA=D1; 18 VAR AGE IQ INCOME; 19 TITLE1 ' type your name here '; 20 RUN;

    Some notes regarding this program:

    Do not type the line numbers that appear on the left (i.e., 1, 2, 3, and so on); these line numbers are provided simply for you to use as a guide.

    On line 19 in the TITLE1 statement, be sure to type your first and last names enclosed in single quotation marks.

    Dont worry if you dont understand the data that are contained in this program or the analysis that it performs. You are only working with this program at this time in order to gain experience with using the SAS windowing environment.

    3. Submit the program, and, if necessary, correct it so that it runs without errors.

    4. Review your log and output windows for possible errors.

  • 8 Step-by-Step Basic Statistics Using SAS: Exercises

    5. When you are sure that your program ran correctly without errors, print your SAS program, SAS log, and SAS output.

    What You Will Hand In

    Hand in the following materials stapled together in this order:

    1. A printout of your SAS program. At the top of this printout, write Exercise 3.2 and your first and last names.

    2. A printout of your SAS log.

    3. A printout of your SAS output. Your SAS output must have your name on it in the title position in order to receive full credit. If you typed your name in the TITLE1 statement of your SAS program correctly, it should appear in the title position on the output.

    Hint

    If your program ran correctly, your output should resemble the following output (except that your name will appear where JOHN DOE now appears):

    JOHN DOE 1

    The MEANS Procedure

    Variable N Mean Std Dev Minimum Maximum -----------------------------------------------------------------

    AGE 9 38.7777778 8.7289429 28.0000000 55.0000000 IQ 9 101.2222222 6.7966495 90.0000000 110.0000000 INCOME 9 39888.89 11307.57 25000.00 58000.00 -----------------------------------------------------------------

  • Exercises for Chapter 4 9

    Exercises for Chapter 4: Data Input Exercise 4.1: Creating and Analyzing a Data Set Containing LAT Test Scores

    Overview

    In this exercise, you will create a small data set and analyze it using PROC MEANS, PROC FREQ, and PROC PRINT. The purpose of the exercise is to give you experience in organizing data, creating valid SAS variable names, using SAS procedures, and, if necessary, debugging programs that contain errors.

    The Study

    Suppose that you are conducting research on a fictitious instrument called the Learning Aptitude Test (LAT). Assume that the LAT is a standardized test that is administered to people (subjects) who plan to go to college, and its scores are used to make admissions decisions. The LAT consists of two subtests: the LAT Verbal subtest, and the LAT Math subtest.

    From a sample study, you obtain scores for nine subjects based on data from the following six variables:

    LAT Verbal subtest. Possible scores can range from 200-800.

    LAT Math subtest. Possible scores can range from 200-800.

    Subject sex. Possible values are F for females and M for males.

  • 10 Step-by-Step Basic Statistics Using SAS: Exercises

    Scores on mid-term test #1, which was given in a general psychology course. Possible scores can range from 0-99.

    Scores on mid-term test #2, which was given in a general psychology course. Possible scores can range from 0-99.

    Scores on mid-term test #3, which was given in a general psychology course. Possible scores can range from 0-99.

    Data Set to Be Analyzed

    Table 4.E1.1 provides data for the nine subjects using the previously discussed six variables. The Subject number column in the table lists a unique number for each subject.

    Table 4.E1.1

    Data from the LAT Study ________________________________________________________

    Scores on mid-term tests ______________

    Subject LAT LAT number Verbal Math Sex #1 #2 #3 ________________________________________________________

    01 510 520 F 89 92 92 02 530 . M 88 75 89 03 620 600 F 95 90 88 04 . 490 F 80 . 78 05 650 600 M 97 95 96 06 550 510 F 76 70 78 07 420 480 . 88 81 85 08 400 410 M 90 88 88 09 590 610 F 90 92 95 ________________________________________________________

  • Exercises for Chapter 4 11

    Your Assignment

    1. Write a SAS program that will input and analyze the preceding data set. When you write the DATA step of this program, do the following:

    Use the SAS programs presented in Chapter 4, Data Input of the Student Guide as models.

    Type all of the information from Table 4.E1.1. You should type the subject number variable that appears as the first column in the table. Give this variable the SAS variable name SUB_NUM. When you type this SAS variable name, make sure you use an underscore (_) and not a hyphen (-). When you type subject numbers such as 01, make sure you type a zero (0) and not the letter O.

    Create SAS variable names for the other variables in the table. Make sure that the SAS variable names you create are meaningful and conform to the rules for SAS variable names presented in Chapter 4 of the Student Guide. Also, remember not to use hyphens in your SAS variable names.

    The periods that appear in the preceding table represent missing data. Be sure that you type these periods in your SAS program as well.

    2. When you write the PROC step of this program, do the following:

    Use PROC MEANS to analyze the following numeric variables: LAT Verbal scores, LAT Math scores, mid-term test #1, mid-term test #2, and mid-term test #3.

    Insert a TITLE1 statement after this PROC MEANS statement. Type your full name in the TITLE1 statement so that it will appear on the output.

    Use PROC FREQ to analyze the sex variable. Use PROC PRINT to create a printout of the raw data. Omit the VAR

    statement so that it will print out the raw data for all variables in the data set.

    3. Submit the program, and if necessary, correct it so that it runs without errors.

    4. Review your log window for possible errors.

  • 12 Step-by-Step Basic Statistics Using SAS: Exercises

    5. Review your output window for possible errors. First, review the results of PROC MEANS and PROC FREQ for errors in the SAS program, as described in Chapter 4, Interpreting the Results Produced by PROC MEANS and Interpreting the Results Produced by PROC FREQ. Next, check the results of PROC PRINT against Table 4.E1.1 to verify that you typed your data correctly.

    What You Will Hand In

    Hand in the following materials stapled together in this order:

    1. A printout of your SAS program.

    2. A printout of your SAS log.

    3. A printout of your SAS output.

    Hints

    If your SAS program ran correctly, your output should resemble the following output (except that your name will appear where JOHN DOE now appears). You do not necessarily have to use the SAS variable names that appear in this output.

    JOHN DOE 1

    The MEANS Procedure

    Variable N Mean Std Dev Minimum Maximum -----------------------------------------------------------------

    LAT_V 8 533.7500000 89.2728562 400.0000000 650.0000000 LAT_M 8 527.5000000 70.8620390 410.0000000 610.0000000 TEST_1 9 88.1111111 6.5849154 76.0000000 97.0000000 TEST_2 8 85.3750000 9.0386077 70.0000000 95.0000000 TEST_3 9 87.6666667 6.5000000 78.0000000 96.0000000 -----------------------------------------------------------------

  • Exercises for Chapter 4 13

    JOHN DOE 2

    The FREQ Procedure

    Cumulative Cumulative SEX Frequency Percent Frequency Percent --------------------------------------------------------

    F 5 62.50 5 62.50 M 3 37.50 8 100.00

    Frequency Missing = 1

    JOHN DOE 3

    Obs SUB_NUM LAT_V LAT_M SEX TEST_1 TEST_2 TEST_3

    1 1 510 520 F 89 92 92 2 2 530 . M 88 75 89 3 3 620 600 F 95 90 88 4 4 . 490 F 80 . 78 5 5 650 600 M 97 95 96 6 6 550 510 F 76 70 78 7 7 420 480 88 81 85 8 8 400 410 M 90 88 88 9 9 590 610 F 90 92 95

  • 14 Step-by-Step Basic Statistics Using SAS: Exercises

    Exercise 4.2: Creating and Analyzing a Data Set Containing Information About Volunteerism

    Overview

    In this exercise, you will create a small data set and analyze it using PROC MEANS, PROC FREQ, and PROC PRINT. The purpose of the exercise is to give you experience in organizing data, creating valid SAS variable names, using SAS procedures, and, if necessary, debugging programs that contain errors.

    The Study

    Suppose that you are a sociologist conducting research on volunteerism. You have interviewed 11 people (subjects) and have asked them if they have served as a volunteer in their community during the past year. You also asked them about their income, and obtained some demographic information (e.g., age, sex).

    Now you need to obtain some descriptive statistics for your data. You will compute means for the numeric variables, and you will create frequency tables for the character variables. You will also print out the raw data set.

    From the study, you obtain data for 11 subjects based on the following six variables:

    Subject number. Represents a unique subject number that is assigned to each subject.

    Age. Represents each subjects age in years.

    Sex. Represents each subject's sex. Here, F represents female subjects and M represents male subjects.

    Race. Represents each subject's race. Here, AF represents African Americans, AS represents Asian Americans, and CA represents Caucasians.

    Income. Represents each subjects annual income in dollars.

  • Exercises for Chapter 4 15

    Served as volunteer? Indicates whether the subject has served as a volunteer during the past year. Y means yes, and N means no.

    Data Set to Be Analyzed

    Table 4.E2.1 provides data for the 11 subjects.

    Table 4.E2.1

    Data from the Volunteerism Study ________________________________________________

    Subject Served as number Age Sex Race Income volunteer? ________________________________________________

    01 20 F AF 75000 Y 02 32 F AF . Y 03 34 M CA 26000 Y 04 . M CA 31000 N 05 29 F CA 23000 Y 06 41 F AS 29000 Y 07 58 . AS 59000 N 08 37 . CA 28000 N 09 25 M CA 1000 Y 10 39 M AF 55000 Y 11 44 F CA 50000 N ________________________________________________

    Your Assignment

    1. Write a SAS program that will input and analyze the preceding data set. When you write the DATA step of this program, do the following:

    Use the SAS programs presented in Chapter 4, Data Input of the Student Guide as models.

    Type all of the information from Table 4.E2.1. You should type the subject number variable that appears as the first column in the table. Give this variable the SAS variable name SUB_NUM. When you type this SAS variable name, make sure you use an underscore (_) and not a

  • 16 Step-by-Step Basic Statistics Using SAS: Exercises

    hyphen (-). When you type subject numbers such as 01, make sure you type a zero (0) and not the letter O.

    Create SAS variable names for the other variables in the table. Make sure that the SAS variable names you create are meaningful and conform to the rules for SAS variable names presented in Chapter 4 of the Student Guide. Also, remember not to use hyphens in these SAS variable names.

    The periods in the preceding table represent missing data. Be sure to type these periods in your SAS data set.

    2. When you write the PROC step of this program, do the following:

    Use PROC MEANS to analyze the following numeric variables: Subject number, age, and income.

    Insert a TITLE1 statement after this PROC MEANS statement. Type your full name in the TITLE1 statement so that it will appear on the output.

    Use PROC FREQ to analyze the following character variables: sex, race, and the served as a volunteer? variable.

    Use PROC PRINT to create a printout of the raw data. Omit the VAR statement so that it will print out the raw data for all variables in the data set.

    3. Submit the program, and, if necessary, correct it so that it runs without errors.

    4. Review your log window for possible errors.

    5. Review your output window for possible errors. First, review the results of PROC MEANS and PROC FREQ for errors in the SAS program, as described in Chapter 4, Interpreting the Results Produced by PROC MEANS and Interpreting the Results Produced by PROC FREQ. Next, check the results of PROC PRINT against Table 4.E2.1 to verify that you typed your data correctly.

  • Exercises for Chapter 4 17

    What You Will Hand In

    Hand in the following materials stapled together in this order:

    1. A printout of your SAS program.

    2. A printout of your SAS log.

    3. A printout of your SAS output.

    Hints

    If your SAS program ran correctly, your output should resemble the following output (except that your name will appear where JOHN DOE now appears). You do not necessarily have to use the SAS variable names that appear in this output.

    JOHN DOE 1

    The MEANS Procedure

    Variable N Mean Std Dev Minimum Maximum -----------------------------------------------------------------

    SUB_NUM 11 6.0000000 3.3166248 1.0000000 11.0000000 AGE 10 35.9000000 10.6921570 20.0000000 58.0000000 INCOME 10 37700.00 21628.43 1000.00 75000.00 -----------------------------------------------------------------

  • 18 Step-by-Step Basic Statistics Using SAS: Exercises

    JOHN DOE 2

    The FREQ Procedure

    Cumulative Cumulative SEX Frequency Percent Frequency Percent --------------------------------------------------------

    F 5 55.56 5 55.56 M 4 44.44 9 100.00

    Frequency Missing = 2

    Cumulative Cumulative RACE Frequency Percent Frequency Percent ---------------------------------------------------------

    AF 3 27.27 3 27.27 AS 2 18.18 5 45.45 CA 6 54.55 11 100.00

    Cumulative Cumulative VOLUNT Frequency Percent Frequency Percent -----------------------------------------------------------

    N 4 36.36 4 36.36 Y 7 63.64 11 100.00

  • Exercises for Chapter 4 19

    JOHN DOE 3

    Obs SUB_NUM AGE SEX RACE INCOME VOLUNT

    1 1 20 F AF 75000 Y 2 2 32 F AF . Y 3 3 34 M CA 26000 Y 4 4 . M CA 31000 N 5 5 29 F CA 23000 Y 6 6 41 F AS 29000 Y 7 7 58 AS 59000 N 8 8 37 CA 28000 N 9 9 25 M CA 1000 Y 10 10 39 M AF 55000 Y 11 11 44 F CA 50000 N

  • 20 Step-by-Step Basic Statistics Using SAS: Exercises