BookmarkSubscribeRSS Feed
reddyr1
Calcite | Level 5

%macro eye (eye,dat, id);

data adae ;

  set adamdata.adae;

   if STUDYGR1 ='Y' and AECAT=&eye and TRTEMFL='Y'  and AEBODSYS ne '' 1 ; *'Ocular';

   where &cond1;

    run;

proc sql ;

                                /*Number of subjects TRTAN */

  create table any as select  trtan, count(distinct usubjid) as cnt from adae where trtan ne . group by  trtan;

  create table soc as select AEBODSYS,trtan, count(distinct usubjid) as cnt from adae where trtan ne . group by AEBODSYS,trtan;

  create table pt as select AEDECOD, AEBODSYS, trtan, count(distinct usubjid) as cnt from adae where trtan ne . group by AEDECOD,AEBODSYS,trtan;

  quit;

------

%mend eye;

The where condition(in red color) needs to be modified for each table.

Eg: where ethnicity="Hispanic"

where ethnicity="Not Hispanic"

where sex="Female"

where sex="Male"

where agegr1n=1

where agegr1n=2

where agegr1n=3

where agegr1n=4


I need to pass all these where conditions in one program.How can i do that?



1 REPLY 1
Reeza
Super User

Change the macro to have an additional parameter COND

Create a data set will the parameters you need to call the macro and use call execute

 

%macro eye (eye,dat, id, cond);

 

..

%mend;

 

Your PROC SQL tables will get overwritten with each run though as they will all have the same name.

 

My example of call execute:

https://gist.github.com/statgeek/beb97b1c6d4517dde3b2

 

SAS Documentation example for call execute:

http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000543697.htm

 

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