BookmarkSubscribeRSS Feed
joseph626
Obsidian | Level 7

I'm looking for a way using macros to deal with a bunch of mixed models...the task is very similar to selection in linear regression:

the first model is: score = var1,

code is like that

PROC MIXED data=model METHOD=ML COVTEST;
  CLASS group;
  MODEL score = var1/SOLUTION;
  RANDOM INTERCEPT /SUB=ID TYPE=UN G;
run;

then it's score = var1 var2, then score = var1 var2 var3... I have up to 7 variables in all, and the criteria is log rank test.

 

Thanks!

 

 

 

 

 

 

1 REPLY 1
Shmuel
Garnet | Level 18

Try next code:

 

%macro run_model(modl , vars=v1 v2 v3 v4 ...  );  /* define as many as need variables */

      %let n = %sysfunc(countw(&vars));

      %do i=1 %to &n;

              %let pos=%sysfunc(findw(&vars, %scan(&vars,&n)));

              %let len = %eval(&pos + %length(%scan(&vars,&n));

               PROC MIXED data=&modl METHOD=ML COVTEST;

             CLASS group;

             MODEL score = %substr(&vars,1,&len)/SOLUTION;

              RANDOM INTERCEPT /SUB=ID TYPE=UN G;

        run;

       %end;

%mend run_model;

%run_model(model,vars=var1 var2 var3);

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 889 views
  • 0 likes
  • 2 in conversation