Dear SAS experts, may I ask for your help again...
I need to run mixed models with hundreds of metabolites as the outcomes. I created this macro variable:
193 %put &biomarker;
XXLVLDLP XXLVLDLL XXLVLDLPL XXLVLDLC XXLVLDLCE
Proc mixed for each of the metabolites individually works
proc mixed data=met method=ML;
class final_id bmi_cat;
model XXLVLDLP=bmi_cat gw cohort/ solution ddfm=satterthwaite cl alpha=0.001;
random intercept time/ subject=final_id type=un;
repeated /subject=final_id type=ar(1);
run;
Macro for proc glm works too.
%macro glm;
proc glm data=met;
model &biomarker=maternal_age/ clparm noint;
ods output ParameterEstimates=dPara; quit;
run;
%mend glm;
But when I try to run this macro for proc mixed
%macro mixed;
proc mixed data=met method=ML;
class final_id bmi_cat;
model &biomarker = bmi_cat gw cohort/ solution ddfm=satterthwaite cl alpha=0.001;
random intercept time/ subject=final_id type=un;
repeated /subject=final_id type=ar(1);
run;
%mend mixed;
it gives me this mistake
1 proc mixed data=met method=ML; class final_id bmi_cat; model &biomarker = bmi_cat gw
-
22
200
1 ! cohort/ solution ddfm=satterthwaite cl alpha=0.001; random intercept time/ subject=final_id
1 ! type=un; repeated /subject=final_id type=ar(1); ods output solutionf=a; run;
NOTE: Line generated by the macro variable "BIOMARKER".
1 XXLVLDLP XXLVLDLL XXLVLDLPL XXLVLDLC XXLVLDLCE
--------
73
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, *, -, /, :, @,
_CHARACTER_, _CHAR_, _NUMERIC_, |.
ERROR 200-322: The symbol is not recognized and will be ignored.
I would really appreciate if you could let me know what I'm doing wrong...
Hello @Polina_UH,
You can use the %SCAN function to extract the individual biomarker names, one at a time, from your macro variable and use the results in the MODEL statement:
%macro mixed; %local i biom; %do i=1 %to %sysfunc(countw(&biomarker)); %let biom=%scan(&biomarker, &i); proc mixed data=met method=ML; class final_id bmi_cat; model &biom = bmi_cat gw cohort/ solution ddfm=satterthwaite cl alpha=0.001; random intercept time/ subject=final_id type=un; repeated /subject=final_id type=ar(1); run; %end; %mend mixed;
Also, note that a multivariate analysis (with more than one dependent variable, as you did it with PROC GLM) is not just an abbreviated way to conduct several univariate analyses.
Maxim 1: Read the Documentation.
From the documentation of The Mixed Procedure:
MODEL dependent = <fixed-effects> </ options>;
The MODEL statement names a single dependent variable and the fixed effects, which determine the matrix of the mixed model (see the section Parameterization of Mixed Models for details). The specification of effects is the same as in the GLM procedure; however, unlike PROC GLM, you do not specify random effects in the MODEL statement. The MODEL statement is required.
(emphasis by me)
You cannot use more than one dependent variable in the model statement of proc mixed.
Thank you, @Kurt_Bremser
Hello @Polina_UH,
You can use the %SCAN function to extract the individual biomarker names, one at a time, from your macro variable and use the results in the MODEL statement:
%macro mixed; %local i biom; %do i=1 %to %sysfunc(countw(&biomarker)); %let biom=%scan(&biomarker, &i); proc mixed data=met method=ML; class final_id bmi_cat; model &biom = bmi_cat gw cohort/ solution ddfm=satterthwaite cl alpha=0.001; random intercept time/ subject=final_id type=un; repeated /subject=final_id type=ar(1); run; %end; %mend mixed;
Also, note that a multivariate analysis (with more than one dependent variable, as you did it with PROC GLM) is not just an abbreviated way to conduct several univariate analyses.
Thank you so much, @FreelanceReinh , it worked!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.