Unmatched quotation mark issue in SAS

喜你入骨 提交于 2019-12-01 21:14:42

When using the macro language (including the %let command) you do not want to use quotes to identify text strings. To place a single quote in a string you must use one of the macro utility masking functions such as %str(). The correct syntax to place a single unmatched quote in a macro variable using %let is shown below. The % symbol before the single quote is an escape character to tell SAS that the following character (a single quote) should be used as a literal. Also note that I've removed the double quotes from the %let as they are not required.

%let quoted=%str(I%'d like to);
data temp;    
    quoted="&quoted";
run;

Cheers Rob

I'm not sure what you're trying to achieve in the actual situation, but in the above situation it can be solved removing the double quotation marks in the data step.

%let quoted="I'd like to";
data temp;
    set temp;
    quoted=&quoted;
run;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!