/**************************************** SAS Example -- Regression II Dummy Variables Polynomial Regression Transformations ****************************************/ title; options pageno=1; libname labdata "c:\temp\labdata"; title "Descriptive Statistics for Each Age Group"; proc means data=labdata.werner; class agegrp; var age ht wt pill chol alb calc uric; run; 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; proc sort data=labdata.werner; by agegrp; run; title "Boxplot of Cholesterol By Age Group"; proc boxplot data=labdata.werner; plot chol*agegrp / boxstyle=schematic; run; title "Regression With Dummy Variables for Age"; proc reg data=labdata.werner; 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.werner; model chol = agedum1 agedum2 agedum3; run; quit; title "Oneway ANOVA with AGEGRP as Factor"; proc glm data=labdata.werner; class agegrp; model chol = agegrp / solution; means agegrp / tukey; run; quit; /************************************** Create new variables for polynomial regression. To do this, we create a new temporary data set. *****************************************/ proc means data=labdata.werner; var age; run; data werner2; set labdata.werner; centage = age - 33.8; centage_sq = centage*centage; run; goptions reset=all; goptions device=win target=winprtm; symbol1 color=black value=dot height=.5 interpol=rq; title "Scatter Plot with Quadratic Regression Line"; proc gplot data=werner2; plot chol * age ; run; title "Quadratic Regression with Centered Variables"; proc reg data=werner2; model chol = centage centage_sq; run; quit; title "Check Possible Box-Cox Transformations"; proc transreg data=werner2; model boxcox(chol) = identity(age); run;