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 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!

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