Kavitha
Kavitha

Reputation: 371

How to escape the ' character in sas

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.

Upvotes: 0

Views: 1029

Answers (2)

Chris J
Chris J

Reputation: 7769

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.""" ; 

Upvotes: 3

mjsqu
mjsqu

Reputation: 5452

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 ';

Upvotes: 2

Related Questions