在 sas 中循环遍历宏中的参数
looping through arguments in a macros in sas
我开发了一个 SAS 代码,它有一个带有两个参数的宏。
宏看起来像这样
%macro compare(country,attributes)
问题是我有 10 个国家,例如印度、U.S.A、澳大利亚、巴基斯坦等,还有 15 个属性,例如语言、地区、货币、life_expec、MaleFemaleRatio 等
所以我要调用宏150次。
%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 */
*;
*;
*;
有什么方法可以把这些属性和国家名称作为数组循环遍历得到相同的结果吗? SAS新手。在此先感谢您对我的帮助
我建议 1. 将您的国家和属性放入 SAS table 'country_attr',变量 'country' 和 'attributes'。 2.调用执行:
data _null_;
set country_attr;
call execute ('%compare('||country||','||attributes')');
run;
我开发了一个 SAS 代码,它有一个带有两个参数的宏。 宏看起来像这样
%macro compare(country,attributes)
问题是我有 10 个国家,例如印度、U.S.A、澳大利亚、巴基斯坦等,还有 15 个属性,例如语言、地区、货币、life_expec、MaleFemaleRatio 等
所以我要调用宏150次。
%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 */
*;
*;
*;
有什么方法可以把这些属性和国家名称作为数组循环遍历得到相同的结果吗? SAS新手。在此先感谢您对我的帮助
我建议 1. 将您的国家和属性放入 SAS table 'country_attr',变量 'country' 和 'attributes'。 2.调用执行:
data _null_;
set country_attr;
call execute ('%compare('||country||','||attributes')');
run;