/************************************************************ * Macro Quoting * * SAS will mask some special characters in macro variable * in order to treat them as text. Sometimes, we need manually * unmask the macro variable to make it work as intended. * * Peng Zeng (Auburn University) * 10-17-2018 ************************************************************/ /* Turn on SYMBOLGEN to check the results of resolving macro * variable references */ options symbolgen; /* The following SAS shows error * Macro variable TESTVAL resolves to 'aaa' * ERROR 386-185: Expecting an arithmetic expression. */ %let val = aaa; %let testval = %str(%'&val%'); data _null_; val = &testval; put 'VAL = ' val; run; /* The following SAS is correct * Macro variable TESTVAL resolves to 'aaa' */ %let val = aaa; %let testval = %str(%'&val%'); data _null_; val = %unquote(&testval); put 'VAL = ' val; run; /* The following SAS shows error * Macro variable TESTVAL resolves to aaa * Variable aaa is uninitialized */ %let val = aaa; %let testval = %str(&val); data _null_; val = %unquote(&testval); put 'VAL = ' val; run;