Unmatched quotation mark issue in SAS

前端 未结 2 2001
刺人心
刺人心 2021-01-21 10:19

As is known to all, SAS needs special care to quotation marks inside a sentence.

E.g.

%let quoted=\"I\'d like to\";
data temp;
    set temp;
    quoted=\         


        
相关标签:
2条回答
  • 2021-01-21 10:57

    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;
    
    0 讨论(0)
  • 2021-01-21 11:04

    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

    0 讨论(0)
提交回复
热议问题