0

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

1 Answer 1

4

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;
Sign up to request clarification or add additional context in comments.

4 Comments

Both of them are not having same length. So is it possible?
Length? If you are referring variable/macro variable length, then it shouldn't matter. Just make sure when you build your SAS table, the length you set is large enough to host them.
is there any other way ? using loop ?
This is Loop, the data step implicit loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.