How to escape the ' character in sas

六月ゝ 毕业季﹏ 提交于 2019-12-25 01:51:08

问题


I want to create a new variable as EVENT with the condition that :IF WORK='Active' AND CONDITION = 'planned convenience removal-no maint. req'd.' THEN EVENT='ISH '; But How to escape the ' character in sas.

SL  WORK    CONDITION
1   Node    part replaced or repaired
2   Active  planned (convenience) removal-maint. req'd.
3   Active  planned convenience removal-no maint. req'd.
4   Active  prop strike
5   Node    planned convenience removal-no maint. req'd.

I tried percent symbol and tried ' ' double quote, its not working.


回答1:


Double-quotes mask single quotes in statements like this, e.g.:

IF WORK='Active' AND CONDITION = "planned convenience removal-no maint. req'd." THEN EVENT='ISH ';



回答2:


To embed a single or double quote in a string, simply insert two consecutively, depending on the type of quotes the string is wrapped within.

e.g.

/* embed a single quote in single-quoted string */
string = 'My name''s Dave.' ;
/* embed double quotes in double-quoted string */
string = "He said ""Let's go out somewhere.""" ; 


来源:https://stackoverflow.com/questions/23106014/how-to-escape-the-character-in-sas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!