/**************************************** SAS Example -- Regression II Dummy Variables ****************************************/ title; options pageno=1; OPTIONS FORMCHAR="|----|+|---+=|-/\<>*"; libname labdata "f:\510\2007\"; data labdata.werner2; set labdata.werner; /*CREATE AGEGRP AND AGE INDICATOR DUMMY VARIABLES*/ if age not=. then do; if age < 25 then agegrp = 1; if age >=25 and age <32 then agegrp=2; if age >= 32 and age < 42 then agegrp = 3; if age >= 42 then agegrp = 4; AGEDUM1 = (AGEGRP = 1); AGEDUM2 = (AGEGRP = 2); AGEDUM3 = (AGEGRP = 3); AGEDUM4 = (AGEGRP = 4); end; if pill = 1 then pilldum = 0; if pill = 2 then pilldum = 1; run; title "Descriptive Statistics for Pill vs. No Pill"; proc means data=labdata.werner; class pill; var age ht wt pill chol alb calc uric; run; proc sort data=labdata.werner2; by pill; run; goptions device=win target=winprtm; title "Boxplot of Cholesterol By Pill"; proc boxplot data=labdata.werner2; plot chol*pill / boxstyle=schematic; run; title "Independent Samples t-test to Compare Mean of Cholesterol"; title2 "For Pill vs. No Pill"; proc ttest data=labdata.werner2; class pill; var chol; run; title "Linear Regression with Pilldum as the Predictor"; proc reg data=labdata.werner2; model chol = pilldum; run; quit; /*********************************************** Look at AGE and AGEGRP ************************************************/ proc sort data=labdata.werner; by age; run; title "Boxplot of Cholesterol By Age"; proc boxplot data=labdata.werner; plot chol*age / boxstyle=schematic; run; title "Simple Regression with AGE as Predictor"; proc reg data=labdata.werner2; MODEL CHOL=AGE; run; quit; title "Descriptives by Levels of AGEGRP"; proc means data=labdata.werner2; class agegrp; var ht wt pill chol alb calc uric; run; proc sort data=labdata.werner2; by agegrp; run; title "Boxplot of Cholesterol By Agegrp"; proc boxplot data=labdata.werner2; plot chol*agegrp / boxstyle=schematic; run; title "Regression With Dummy Variables for AgeGRP"; proc reg data=labdata.werner2; model chol = agedum2 agedum3 agedum4; plot rstudent.*predicted.; output out=regdat1 p=predict r=resid rstudent=rstudent; run; quit; title "Check Distribution of Residuals"; proc univariate data=regdat1; var rstudent; histogram; qqplot / normal (mu=est sigma=est); run; title "Dummy Variables with Age 4 as Ref Category"; proc reg data=labdata.werner2; model chol = agedum1 agedum2 agedum3; run; quit; title "Oneway ANOVA with AGEGRP as a Factor"; proc glm data=labdata.werner2; class agegrp; model chol = agegrp / solution; means agegrp / tukey; run; quit;