Reputation: 1450
Suppose I have a dataset with variables named var1
and var1_test
. I am writing a macro with input var1
. Now I am looking for a way to create var1_test
from var1
and the string "_test"
. Eventually, I want to use this variable in a where condition. I tried the following:
%macro some_name(var =);
%let var2 = %sysfunc(catx(&var., '_test'));
proc sql;
select ...
from ...
where &var2. = 1;
quit;
%mend;
Upvotes: 0
Views: 2514
Reputation: 63424
You don't need to use cat
functions with macro variables in the macro language. They're just open text, so just putting more text next to them automatically concatenates.
%let var2 = &var._test;
You're also using the wrong CAT function, catx
is for putting a delimiter in the middle so the first argument is the delimiter (so it would not concatenate anything, as it only sees one thing to concatenate). You also have quotation marks around the argument, which are not correct in %sysfunc
- quotation marks in that context are treated as actual characters, not as string delimiters.
Upvotes: 1