I am trying to combine the odds ratios outputted from two models with different adjustments in SAS:
i.e:
ods output oddsratios=adjustedOR1(rename=(OddsRatioEst=OR1);
proc logistic data=dataname;
model y= b d c a e; run;
ods output oddsratios=adjustedOR2 (rename=(OddsRatioEst=OR2);
proc logistic data=dataname;
model y= b d c; run;
proc sort…..
data Oddsratios (keep=Effect OR1 OR2);
merge adjustedOR1 adjustedOR2; by effect; run;
Problem is that if I sort and merge by the Effect variable, I lose the order in which I put the explanatory variables in the model.
Is there anyway to assign an index to the variable according to the order I put it in the model, so that the final table will have the effect column in the order: b d c a e?
Thanks for your help
I suggest creating a new sequence variable in your “primary” dataset with the sort order you want. then re-sorting the merged result by that variable:
This would be a bit more generic than hard-coding the sort sequence as Keith suggests using PROC SQL (which also works by the way).
And thanks to Keith for providing a practical example!