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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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