BookmarkSubscribeRSS Feed
Tpham
Quartz | Level 8

I am very new to Macros and  I have a quick question.. How do I input in two variables in a macro?

%MACRO Table2adj (exp=);

PROC SURVEYLOGISTIC DATA =temp nomcar;

STRATA sdmvstra;

CLUSTER sdmvpsu;

WEIGHT MEC10YR;

DOMAIN sel;

CLASS &exp (REF='0') agegp (ref='3.30-39') martial (REF='4.never married') race (REF='1.NH White') edu (REF='HS') employ (REF='0')

income (REF='55+') healthstatus (REF='good')  alcohol_abuse (REF='1.Low/No Risk') smoke (REF='0.never smoke')  drug (REF='0');

MODEL haveins (event='1')= &exp agegp martial race edu employ income healthstatus Charlston_Score

/clparm vadjust=none;

run;

PROC SURVEYLOGISTIC DATA =temp nomcar;

STRATA sdmvstra;

CLUSTER sdmvpsu;

WEIGHT MEC10YR;

DOMAIN sel;

CLASS &exp (REF='0') agegp (ref='3.30-39') martial (REF='4.never married') race (REF='1.NH White') edu (REF='HS') employ (REF='0')

income (REF='55+') healthstatus (REF='good')  alcohol_abuse (REF='1.Low/No Risk') smoke (REF='0.never smoke')  drug (REF='0');

MODEL healthvisit (event='1')= &exp agegp martial race edu employ income healthstatus Charlston_Score

/clparm vadjust=none;

run;

%MEND Table2adj;

%Table2adj(exp=Male);

So the code above,  I inserted the variable Male for &exp.. The two proc surveylogistic are identical with exception of the outcome. So I am wondering is there a way to insert Male and insert healthvisit? This is a simplified example, I have multiple procs to run.

1 REPLY 1
LinusH
Tourmaline | Level 20

If you want them in the same execution, just line them up in the macro call separated by space (as they would in the proc logic.

If you want separate executions, just call the macro twice and changing the parameter.

Data never sleeps

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1919 views
  • 0 likes
  • 2 in conversation