/************************************************************ Descriptive statistics, graphics for the Classroom Data set *************************************************************/ PROC IMPORT OUT= WORK.classroom DATAFILE= "c:\temp\classroom.csv" DBMS=CSV REPLACE; GETNAMES = YES; DATAROW = 2; GUESSINGROWS = 20; RUN; /******************************************************* Descriptive Summary ********************************************************/ title "Level 1 Descriptive Statistics"; proc means data = classroom; var sex minority mathkind mathgain ses; run; /***************************************************** Generate Level 2 data set ******************************************************/ proc sort data = classroom; by classid; run; data level2; set classroom; by classid; if first.classid then output; run; title "Level 2 Descriptive Statistics"; proc means data = level2; var yearstea mathknow mathprep; run; /***************************************************** Generate Level 3 data set ******************************************************/ proc sort data = classroom; by schoolid; run; data level3; set classroom; by schoolid; if first.schoolid then output; run; title "Level 3 Descriptive Statistics"; proc means data = level3; var housepov; run; /************************************************************ Renumber the classrooms within each school (e.g., 1,2,3...312), rather than (160, 217, 197, etc.) before making the boxplot, to make it more readable. *************************************************************/ proc sort data=classroom; by schoolid classid; run; data classroom_renum; set classroom; by schoolid classid; if first.schoolid then classnum = 0; if first.classid then classnum+1; run; proc print data=classroom_renum(obs=35); run; title "Boxplots of MATHGAIN for First 8 Schools"; proc sgpanel data = classroom_renum (where = (schoolid <= 8)); panelby schoolid / columns = 4 noheaderborder columns = 4; vbox mathgain / category = classnum; colaxis display = (novalues noticks); run; /************************************************************ Descriptive Summary #2: With no missing values. Remove cases with missing values for MATHKNOW *************************************************************/ data classroom_nomiss; set classroom; if mathknow ne .; run; title "Level 1 Descriptive Statistics"; title2 "No Missing Data"; proc means data = classroom_nomiss; var sex minority mathkind mathgain ses; run; /*Generate Level 2 data set*/ proc sort data = classroom_nomiss; by classid; run; data level2_nomiss; set classroom_nomiss; by classid; if first.classid then output; run; title "Level 2 Descriptive Statistics"; title2 "No Missing Data"; proc means data = level2_nomiss; var yearstea mathknow mathprep; run; /*Generate Level 3 data set*/ proc sort data = classroom_nomiss; by schoolid; run; data level3_nomiss; set classroom_nomiss; by schoolid; if first.schoolid then output; run; title "Level 3 Descriptive Statistics"; title2 "No Missing Data"; proc means data = level3_nomiss; var housepov; run;