/* The following from section 2.3 */ /* Assume sasclass has already been associated with c:\temp */ /* Use the CONTENTS procedure to get an overview of */ /* the data set */ PROC CONTENTS DATA = sasclass.bankdata ; /* Print out the data */ PROC PRINT DATA = sasclass.bankdata ; RUN ; /* From section 3.1 */ /* Get the numbers of males and females */ PROC FREQ DATA = sasclass.bankdata ; TABLES gender ; PROC MEANS DATA = sasclass.bankdata ; VAR salary ; RUN ; /* From section 3.2 */ /* Recode the missing values */ /* Create the new dataset bankdata2 */ /* Temporary datasets are stored in the WORK */ /* library and are deleted at the end of the */ /* SAS session */ DATA bankdata2; set sasclass.bankdata ; MISSING X; IF jobcat = "X" THEN jobcat =. ; IF gender = " " THEN gender =. ; RUN ; PROC FREQ ; TABLES jobcat gender ; RUN; /* Section 3.3 */ /* Add labels to the bankdata2 data set */ PROC DATASETS library = sasclass ; MODIFY bankdata2 ; LABEL gender = "Respondant's Sex" educ = 'Number of years of education' preexp = 'Previous experience (months)' bdate = 'Birth year of the respondent' jobtime = 'Months since hired' salary = "Respondent's salary" ; RUN ; /* Get the frequency on gender */ PROC FREQ DATA = bankdata2 ; TABLES gender ; /* Get the means of several variables (with new labels ) */ PROC MEANS DATA = bankdata2 ; VAR educ preexp bdate jobtime salary ; RUN ; /* Section 4 */ /* Sort the data by gender */ PROC SORT DATA = bankdata2 ; BY gender ; /* print the sorted data */ PROC PRINT DATA = bankdata2 ; BY gender ; /* Get a crosstabs on salary/gender */ PROC FREQ ; TABLES salary * gender ; PROC SORT DATA = bankdata2 ; BY gender ; PROC MEANS DATA = bankdata2 ; BY gender ; VAR salary ; RUN ; /* create a permanent dataset called */ /* bankdata3 in the sasclass library */ /* Add a new variable to the data set */ DATA sasclass.bankdata3 ; SET bankdata2 ; IF educ GT 0 and educ LT 12 THEN educ2 = 1 ; ELSE IF educ GE 12 AND educ LE 15 THEN educ2 = 2 ; ELSE IF educ GE 16 THEN educ2 = 3 ; /* Check out the new variable */ PROC FREQ ; TABLES educ ; TABLES educ2 ; RUN ; /* Does salary vary by education level */ PROC SORT DATA = sasclass.bankdata3 ; BY educ2 ; PROC MEANS ; VAR salary ; BY educ2 ; RUN ; /* A cross tabs with the new variable (educ2) */ PROC FREQ ; TABLES educ2 * gender ; RUN ;