First to summarize the situation: I am looking to adjust, lets say the mean blood pressure (amongst numerous other variables) across groups controlling for factors such as age, race, family history. Which based on previous studies and experience I would do something such as this. proc glm data=dataset; class groups; model bloodpressure = groups age race familyhistory; lsmeans groups; run; However it is more complicated than this and I'm actually looking to make more than one table. Lets say in one table I want to calculate the following: Cases Controls Total Low Physical Activity High Physical Activity Adj Mean BP and in the proceeding table: Cases Controls Total Never Smoked Former Smoker Current Smoker Adj Mean BP The problem then lies in that to produce these tables (and potentially more) I run multiple models (inserting the respective grouping variable each time). When you run the glm procedure multiple times it recenters for each run and thus I get different adj means for my controls and total cases. Thus the hierarchal nature of these tables is not maintained in SAS and you can not collapse with consistency (Since again you running in separate models). I've found a way to resolve this in STATA with the following code (Which utilizes one Model), but I hate STATA and would much prefer to remain in SAS and not export my data. Here is how it is accomplished it below: capture program drop AdjMeans program define AdjMeans syntax varname xi: regress `varlist' age race fam_history i.caco_all quietly { * Age * sum age if e(sample) local age1 = r(mean) * Race * sum race if e(sample) local race1 = r(mean) * Family History * sum fam_history if e(sample) local fam_history1 = r(mean) } ** Adjusted Means for Controls, Cases ** adjust age =`age1' race = `race1' fam_history = `fam_history1' if e(sample), by(caco) se gen(lnmean std) drop lnmean std ** Adjusted Means for Controls, Cases (high physical activity vs. low physical activity) ** adjust age =`age1' race = `race1' fam_history = `fam_history1' if e(sample), by(caco_activity) se gen(lnmean std) drop lnmean std ** Adjusted Means for Controls, Cases (Smoking Activity) ** adjust age =`age1' race = `race1' fam_history = `fam_history1' if e(sample), by(caco_smk) se gen(lnmean std) drop lnmean std end AdjMeans bp *note caco_all represents the dummy coding for all groupings i.e: if caco_hi = 1 and caco_neversmoker = 1 then caco_all = 1; else if caco_hi = 1 and caco_formersmoker = 1 then caco_all = 2; else if caco_hi = 1 and caco_currentsmoker = 1 then caco_all = 3; else if caco_lo = 1 and caco_neversmoker = 1 then caco_all = 4; else if caco_lo = 1 and caco_formersmoker = 1 then caco_all = 5; else if caco_lo = 1 and caco_currentsmoker = 1 then caco_all = 6; else if caco = 2 then caco_all = 7; Any insight into alternatives in SAS?
... View more