options ls=85 ps=200 nodate; data cholst; infile "cholst.dat"; input newid id cholst sex age year; if cholst=. then delete; run; proc sort; by newid year; run; proc print data=cholst (obs=20); var newid cholst sex age year; run; title "First stage in two-stage analysis"; proc reg outest=out noprint; model cholst = year; by newid; run; data out; set out; b0hat = intercept; b1hat = year; keep newid b0hat b1hat; run; data main; merge cholst out; by newid; if first.newid=1; run; title "Summary statististics for intercepts and slopes"; proc means mean stderr var t probt; var b0hat b1hat; run; title "Correlation between intercepts and slopes"; proc corr; var b0hat b1hat; run; title "Test equality of mean and variance of intercepts and slopes between sexes"; proc ttest; class sex; var b0hat b1hat; run; title "Regression to look at the association between intercept and age, sex"; proc reg data=main; model b0hat = age sex; run; title "Regression to look at the association between slope and age, sex"; proc reg data=main; model b1hat = age sex; run;