DATA Step, Macro, Functions and more

Repeating a Compiled Macro?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 86
Accepted Solution

Repeating a Compiled Macro?

Hi All

I am not sure whether it was answered before in this community. (Sorry for duplicating). The question is:

If I have a macro with some parameters like this:

%Macro have( A = , B =, C = , D =)

Program goes here...

%Mend

Now, I want to execute this program many times in the program with different set of parameters

%Have ( A = 1 , B = 2 , C = 3, D = 4);

%Have ( A =  3, B = 3 , C =9, D = 6);

.....................................................

......................................................

This look litte ugly to me as repeating a macro progam. Are there other ways where we can produce the same results but looks nice.

Thank you


Accepted Solutions
Solution
‎11-05-2012 12:07 AM
Super User
Posts: 9,671

Re: Repeating a Compiled Macro?

You can use a dataset to hold these parameter, then call execute them.

data x;

input a b c d;

cards;

1 2 3 4

3 3 9 6

;

run;

data _null_;

set x;

call execute( '%have(' || a || ',' || ....................... );run;

View solution in original post


All Replies
Super Contributor
Posts: 1,636

Re: Repeating a Compiled Macro?

Is this better?

%Macro have( A , B , C , D )

Program goes here...

%Mend

Now, I want to execute this program many times in the program with different set of parameters

%Have ( 1 ,  2 ,  3, 4)

%Have (3,  3 , 9,  6)

...................................................

Solution
‎11-05-2012 12:07 AM
Super User
Posts: 9,671

Re: Repeating a Compiled Macro?

You can use a dataset to hold these parameter, then call execute them.

data x;

input a b c d;

cards;

1 2 3 4

3 3 9 6

;

run;

data _null_;

set x;

call execute( '%have(' || a || ',' || ....................... );run;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 182 views
  • 0 likes
  • 3 in conversation