looping through arguments in a macros in sas

2020-05-07 01:53发布

I have developed a SAS code which has a macro with two arguments. The macro looks like this

%macro compare(country,attributes)

The problem is I have 10 countries , for example India, U.S.A, Australia, Pakistan etc and 15 attributes such as language, area, currency, life_expec, MaleFemaleRatio etc.

So I have to call macro for 150 times.

%compare(India,language);
%compare(India,area);
%compare(India,currency);
*  ;
/* Similarly I have do the same for other attributes also */
*   ;
%compare(U.S.A,language)
%compare(U.S.A,area)
/* Similarly I have do the same for other countries also */
*;
*;
*;

Is there any way to take take these attributes and country names as array and loop through them to get same result? New to sas. Thanks in advance for helping me

标签: sas
1条回答
萌系小妹纸
2楼-- · 2020-05-07 02:12

I would suggest 1. Put your country and attributes into a SAS table 'country_attr', with variable 'country' and 'attributes'. 2. Call execute:

data _null_;
 set country_attr;
 call execute ('%compare('||country||','||attributes')');
 run;
查看更多
登录 后发表回答