Search code examples
sassas-macro

Colon modifier in macro


I'm trying to use the colon modifier functionality in a macro but it doesn't seem to work the same way as in a data step. An example of what I'm trying to do is shown below.

data _null_;
str = "hello";
if str =: "h" then put "y";
else put "n";
run;

The if-statement evaluates TRUE in the data step but when I apply similar logic in the macro language this no longer appears to work.

%let str = hello;
%put %eval(&str =: h);

The code above now evaluates to FALSE. Is there something I'm missing here or is this modifier just not available in the macro language? I know I could use %eval(%substr(&str,1,1)=h) but I'm more curious to find out if the : will work.


Solution

  • No, the : is not in the list of macro operators; see the macro language reference for more details.

    Note that =: is also not valid in other places, such as in PROC SQL. In those contexts eqt is the equivalent operator, but that also does not work in the macro language.