jl6
jl6

Reputation: 6422

Dynamically choose name of macro to call?

In SAS, the double/triple/etc ampersand can be used to dynamically choose which macro variable to resolve. Is there an equivalent syntax using double/triple/etc percents?

I tried %%%substr(&x,3) expecting the same resolution rules to be used (i.e. turn %% into %, then call the substring macro, then call the macro with the name of the result) but it is apparently invalid syntax.

Upvotes: 0

Views: 104

Answers (1)

vasja
vasja

Reputation: 4792

You can use macro variable instead of fixed macro name, e.g.:

%let mname=test;

%macro test;
%put I am test.;
%mend;

%&mname

Upvotes: 2

Related Questions