Alex F
Alex F

Reputation: 2274

Append extra characters after a macro variable in SAS?

I have a simple macro where I am passing in a parameter but also want to append onto the macro. However, when I try to add the additional text it won't recognize the original macro variable. I have tried to convert the macro variable to a string first, append the extra text, then unquote it but can't find an appropriate concatenate function to use.

Here is my macro and what isn't working now, with the problem being &del_30 in the third line. The compiler is trying to interpret &del_30 as a macro, instead of &del_ by itself.

%macro plot_better_same_worse(title_, del_);
proc Sgplot data=ALL_TP_NORM_TBL;
SERIES X = asofdt Y = &del_30 /
MARKERS LINEATTRS = (THICKNESS = 2);

run;
%mend plot_better_same_worse;

I have also tried to do this instead: &&del_&30 but SAS tries to interpret &30 as a macro variable as well.

Upvotes: 1

Views: 1268

Answers (1)

Joe
Joe

Reputation: 63424

Macro variable names begin with & and end with ., or the first character illegal to be in a macro variable name (A-Z, 0-9, _).

So &del_.30 would resolve &del_ and then put 30 after it.

Upvotes: 2

Related Questions