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

I have two different data sets, six different outcome variables, and two primary (separate) predictors which I am trying to incorporate into proc logistic along with several covariates using a macro. I'm trying to figure out the most efficient way. My initial thought was:

%macro mod(dat, out, pred);

proc logistic data=&dat; 
model &out=&pred cov1 cov2 cov3 cov4 cov5 cov6 /desc;
run;

%mend mod;
%mod (dat1, out1, pred1);
%mod (dat1, out2, pred1);
%mod (dat1, out3, pred1);
%mod (dat1, out4, pred1);
%mod (dat1, out5, pred1);
%mod (dat1, out6, pred1);
%mod (dat1, out1, pred2);
%mod (dat1, out2, pred2);
%mod (dat1, out3, pred2);
%mod (dat1, out4, pred2);
%mod (dat1, out5, pred2);
%mod (dat1, out6, pred2);
%mod (dat2, out1, pred1);
%mod (dat2, out2, pred1);
%mod (dat2, out3, pred1);
%mod (dat2, out4, pred1);
%mod (dat2, out5, pred1);
%mod (dat2, out6, pred1);
%mod (dat2, out1, pred2);
%mod (dat2, out2, pred2);
%mod (dat2, out3, pred2);
%mod (dat2, out4, pred2);
%mod (dat2, out5, pred2);
%mod (dat2, out6, pred2);

Is there a more efficient way, by referring to the outcome variables only once/nesting the macro? Another, however also inefficient, way is:

%macro mod(out);

proc logistic data=data_one;
model &out=pred1 cov1 cov2 cov3 cov4 cov5 cov6/desc;
run;

proc logistic data=data_one;
model &out=pred2 cov1 cov2 cov3 cov4 cov5 cov6/desc;
run;

proc logistic data=data_two;
model &out=pred1 cov1 cov2 cov3 cov4 cov5 cov6/desc;
run;

proc logistic data=data_two;
model &out=pred2 cov1 cov2 cov3 cov4 cov5 cov6/desc;
run;

%mend mod;
%mod (out1);
%mod (out2);
%mod (out2);
%mod (out3);
%mod (out4);
%mod (out5);
%mod (out6);

Thanks in advance!

 

Em

1 ACCEPTED SOLUTION
3 REPLIES 3
Caetreviop543
Obsidian | Level 7

Hello,

 

I have two data sets, six different outcome variables, and two primary (separate) predictors which I am trying to incorporate into proc logistic along with several covariates using a macro. I'm trying to figure out the most efficient way. My initial thought was:

%macro mod(dat, out, pred);

proc logistic data=&dat; 
model &out=&pred cov1 cov2 cov3 cov4 cov5 cov6 /desc;
run;

%mend mod;
%mod (dat1, out1, pred1);
%mod (dat1, out2, pred1);
%mod (dat1, out3, pred1);
%mod (dat1, out4, pred1);
%mod (dat1, out5, pred1);
%mod (dat1, out6, pred1);
%mod (dat1, out1, pred2);
%mod (dat1, out2, pred2);
%mod (dat1, out3, pred2);
%mod (dat1, out4, pred2);
%mod (dat1, out5, pred2);
%mod (dat1, out6, pred2);
%mod (dat2, out1, pred1);
%mod (dat2, out2, pred1);
%mod (dat2, out3, pred1);
%mod (dat2, out4, pred1);
%mod (dat2, out5, pred1);
%mod (dat2, out6, pred1);
%mod (dat2, out1, pred2);
%mod (dat2, out2, pred2);
%mod (dat2, out3, pred2);
%mod (dat2, out4, pred2);
%mod (dat2, out5, pred2);
%mod (dat2, out6, pred2);

Is there a more efficient way, by referring to the outcome variables only once/nesting the macro? Another, however also inefficient, way is:

%macro mod(out);

proc logistic data=data_one;
model &out=pred1 cov1 cov2 cov3 cov4 cov5 cov6/desc;
run;

proc logistic data=data_one;
model &out=pred2 cov1 cov2 cov3 cov4 cov5 cov6/desc;
run;

proc logistic data=data_two;
model &out=pred1 cov1 cov2 cov3 cov4 cov5 cov6/desc;
run;

proc logistic data=data_two;
model &out=pred2 cov1 cov2 cov3 cov4 cov5 cov6/desc;
run;

%mend mod;
%mod (out1);
%mod (out2);
%mod (out2);
%mod (out3);
%mod (out4);
%mod (out5);
%mod (out6);

Thanks in advance!

Em

Caetreviop543
Obsidian | Level 7

That's interesting! I wouldn't have thought to do it that way...

 

Thanks Reeza!

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 2061 views
  • 0 likes
  • 2 in conversation