I have several outcomes of interest and exposures of interest and I want to run many MLR to see the relationships, but this is very tedious, so I want to know how can I use macro to simplify the process.
My code:
proc glm data = xxx;
model A B C =smoke nutrient smoke*nutrient height Age sex race BMI education;
run;
A, B, and C are my outcomes of interest.
I want to change the "nutrient" in each MLR, e.g. fat, protein, carbs...
So I want to run the model of A and fat, B and fat, C and fat, A and protein, B and protein......
So I want to run the model of A and fat, B and fat, C and fat, A and protein, B and protein......
Please explain further. This seems to contradict your MODEL statement in PROC GLM which has models with 9 or 10 factors.
Hi thank you for reply.
I have 3 outcomes, and 300 of nutrients and smoke as exposures. Others in the right side of the "=" are covariates (confounders). Each time I can only run:
model (1 outcome) = smoke (1 nutrient) smoke*(1 nutrient) height Age sex race BMI education;
So basically I need to loop all the nutrients, otherwise I need to run the model 3*300=900 times.
First, after you run these 900 models, then what will you do with all that information?
Let me suggest a complete change of direction. My suggestion is to stop using linear regression and use Partial Least Squares regression (PROC PLS in SAS). This was specifically designed for cases where you have lots of variables, that are correlated with one another, and multiple response variables. You fit one model, and then PLS tells you which variables are the important predictors, which variables are correlated with one another, and even which of your y-variables are correlated with other y-variables.
One PLS model, which provides a lot of information, or 900 OLS models. I go with PLS almost every time. And therefore, writing a macro to do what you want is unnecessary.
Ok, PLS can do everything you ask, and does it better than linear regressions.
If your problem has to have 900 regressions, then I will leave the problem to others to help you create such a macro.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.