OPTIONS LINESIZE = 80; /*Set the width for 8.5 x 11 paper */ TITLE 'Example 2: SAS Short Course Notes'; TITLE2 'Using the existing SAS dataset from Example 1'; LIBNAME sasdata '.'; DATA scores; SET sasdata.test; IF wgt = . THEN LIST; IF gender = 'M' THEN testotal = testotal + 10; IF gender = 'F' THEN testotal = testotal + 20; IF wgt = . THEN wtclass = . ; ELSE IF wgt GE 0 and wgt LT 160 THEN wtclass = 1 ; ELSE IF wgt GE 160 THEN wtclass = 2 ; PROC PRINT; TITLE2 'List out all current data, showing effect of IFs'; PROC SORT DATA= scores; BY gender; PROC MEANS DATA=scores; BY gender; VAR testotal; TITLE2 'Descriptive statistics listed separately for each gender'; PROC TTEST; CLASS wtclass; VAR testotal; TITLE2 'T-Test of testotal by High vs. Low weight'; PROC FREQ; TABLES wtclass * age; TITLE2 'Crosstabulation, weight by age'; PROC PLOT; PLOT wgt*testotal=gender; TITLE2 'Weight vs. total score labeled by gender'; /******************************************************************/ /* THIS SAS COMMAND FILE DOES THE FOLLOWING: */ /* */ /* Creates a temporary SAS dataset called SCORES, containing */ /* the same information as in the permanent dataset MYLIB.TESTS. */ /* Writes a copy of any observation with WGT missing to the */ /* LOG. */ /* Adds 10 points to the total of test scores for men and 20 */ /* points to the test scores of women. */ /* Creates a dichotomous variable WTCLASS based on WGT */ /* scores. */ /* Sorts the data by the variable "gender". */ /* Produces descriptive statistics separately for male and */ /* female participants. (You must first sort by gender, as in */ /* the SORT command above.) */ /* Runs a t-test to see if there are significant differences */ /* in test scores between those in the high weight category and */ /* those in the low weight category. */ /* Constructs a crosstab (conditional frequency) table of */ /* weight by age. */ /* Draws a scatterplot of weight by age, labeled by gender. */ /* If you need assistance with SAS please contact the statistical */ /* consultants at the ITC Research Computing Support Center at */ /* 244 Wilson Hall - 243-8000 M-F 9-5 or */ /* mail res-consult@virginia.edu */