* Record output to a Word file; ODS RTF FILE = 'C:\Documents and Settings\Rich\Desktop\Rich\LYNAM\May14WorkshopOutput.rtf'; * Read in the data; PROC IMPORT DATAFILE = 'C:\Documents and Settings\Rich\Desktop\Rich\LYNAM\May14WorkshopData.xls' OUT = NewName DBMS = XLS REPLACE; * Supply path and name of Excel file with data, supply new name for data in SAS, change XLS to XLSX if using later version of Excel; SHEET = Sheet1; * Identify tab of Excel file on which data reside; GETNAMES = YES; RUN; * List all variables; PROC CONTENTS data=NewName; RUN; * Print all values of selected variables; PROC PRINT data=NewName; VAR ID Time NegUrg MJ; Run; * Define new variables; data Newname; set Newname; negurgstratum = 0; if negurg > -0.674 then negurgstratum = 1; if negurg > 0.674 then negurgstratum = 2; * Create variable to define three negative urgency strata: 0 (low), 1 (average), 2 (high); run; * Exploratory data analysis; proc means data=Newname n min q1 median q3 max mean stddev skew maxdec=2; * Request summary statistics for variables indicated below; var time negurg mj; run; proc freq data=Newname; where time = 0; * Restrict attention to freshman year; tables mj*negurgstratum / chisq; * Cross tabulate marijuana use and negative urgency strata; run; proc freq data=Newname; where time = 1; * Restrict attention to sophomore year; tables mj*negurgstratum / chisq; * Cross tabulate marijuana use and negative urgency strata; run; proc freq data=Newname; where time = 2; * Restrict attention to junior year; tables mj*negurgstratum / chisq; * Cross tabulate marijuana use and negative urgency strata; run; * Fit generalized linear mixed model with negative urgency as a categorical variable; proc glimmix data=newname method=laplace; class id negurgstratum; * Identify categorical variables; model mj = negurgstratum time*negurgstratum / dist=bin link=logit noint solution; * Identify response and predictors, distribution and link, specify no intercept and request parameter estimates; estimate 'High vs low freshman' negurgstratum -1 0 1 time*negurgstratum 0 0 0 ; estimate 'High vs low sophomore' negurgstratum -1 0 1 time*negurgstratum -1 0 1; estimate 'High vs low junior' negurgstratum -1 0 1 time*negurgstratum -2 0 2; run; * Add random effects for subjects' personal intercepts; proc glimmix data=newname method=laplace; class id negurgstratum; * Identify categorical variables; model mj = negurgstratum time*negurgstratum / dist=bin link=logit noint solution; * Identify response and predictors, distribution and link, specify no intercept and request parameter estimates; estimate 'High vs low freshman' negurgstratum -1 0 1 time*negurgstratum 0 0 0 ; estimate 'High vs low sophomore' negurgstratum -1 0 1 time*negurgstratum -1 0 1; estimate 'High vs low junior' negurgstratum -1 0 1 time*negurgstratum -2 0 2; random intercept / subject=id type=un; * include random effects for subjects' personal intercepts ; run; * Fit generalized linear mixed model with negative urgency as a continuous variable; proc glimmix data=newname method=laplace; class id ; * Identify categorical variables; model mj = negurg time time*negurg / dist=bin link=logit solution; * Identify response and predictors, distribution and link, request parameter estimates; estimate 'High vs low freshman' negurg 2 time*negurg 0 ; estimate 'High vs low sophomore' negurg 2 time*negurg 2 ; estimate 'High vs low junior' negurg 2 time*negurg 4 ; random intercept / subject=id type=un; * include random effects for subjects' personal intercepts ; run; * Cease recording output to a Word file; ODS RTF CLOSE; RUN;