问题描述
我开发了一个 SAS 代码,它有一个带有两个参数的宏.宏看起来像这样
I have developed a SAS code which has a macro with two arguments.The macro looks like this
%macro compare(country,attributes)
问题是我有 10 个国家,例如印度、美国、澳大利亚、巴基斯坦等和 15 个属性,例如语言、地区、货币、life_expec、MaleFemaleRatio 等.
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.
所以我必须调用宏 150 次.
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 */
*;
*;
*;
有没有办法将这些属性和国家名称作为数组并循环遍历它们以获得相同的结果?sas新手.预先感谢您帮助我
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
推荐答案
我建议 1. 将您的国家和属性放入 SAS 表 'country_attr' 中,并带有变量 'country' 和 'attributes'.2. 调用执行:
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;
这篇关于在 sas 中的宏中循环参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!