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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 2516 views
  • 0 likes
  • 2 in conversation