BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Polina_UH
Obsidian | Level 7

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... 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

Maxim 1: Read the Documentation.

 

From the documentation of The Mixed Procedure:

 

MODEL Statement

 

  • 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.

Polina_UH
Obsidian | Level 7

Thank you, @Kurt_Bremser 

FreelanceReinh
Jade | Level 19

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.

Polina_UH
Obsidian | Level 7

Thank you so much, @FreelanceReinh , it worked!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1257 views
  • 2 likes
  • 3 in conversation