Kristi Metzger
Some analyses require running a series of models with the same specifications but with different outcomes. In epidemiologic analyses, we often want to record the results of a crude model (i.e., one with no covariates) and an adjusted model (i.e., one that includes covariates). In these situations, it can be helpful to construct a macro to loop through both the crude and adjusted models and then output the results into data sets using ODS OUTPUT statements. For analyses in which there is potential for an iterative model to not converge (such as for rarer outcomes), it is helpful to also output the convergence status. The convergence status can be used within a macro to automatically direct the analytic process through the desired analyses if convergence is attained or to alternative options if it is not. In this example, I will use a series of repeated-measures generalized estimating equations models in PROC GENMOD to model the rate ratios of specific types of motor vehicle crashes by driver age. For each type of motor vehicle crash, the macro loops through a crude model, then to a partially adjusted model (controlling for a limited number of covariates) then to a fully adjusted model (controlling for all covariates) if the more parsimonious model converges or exits the macro loop if it does not converge. The macro concatenates the results of each model for all outcomes into a single dataset with indicators for the type of model (crude, partially adjusted, or fully adjusted).
View paper.