Search code examples
sas-macro

Don't resolve to macrovariable text returned by %substr() with & at the begining


I'm trying to quote a substring of a macro variable. The code is:

%let hola=resuelto!;

%macro prueba(param);
    %let amper=&param;
    %let amper2=%nrbquote(%substr(&param,1,3));
    %put &param;
    %put &amper;
    %put &amper2;
%mend;

%prueba(%nrstr(&hola));

In the log, I'm getting:

WARNING: Apparent symbolic reference HO not resolved.
&hola
&hola
&ho

The problem is I need to assign amper2 literally the value &ho, without any attempt of resolution, like I do with amper, that gets literally the string &hola... any idea?

Thank you in advance!


Solution

  • Changing

    %nrbquote(%substr(&param,1,3))
    

    to

    %qsubstr(&param,1,3)
    

    should do the trick.