Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SAS Escape Sequence

Status
Not open for further replies.

ApocY85

Programmer
Dec 20, 2007
36
US

I think this question should be easy to answer :)

In every language I know, if you need to include certain characters (for example, a quotation mark) in a string, you must use an escape sequence before that character so the parser doesn't confuse it with some keyword/symbol.

Here is an example:

a_new_string = "John said, \"How are you?\"";

The backslashes let the parser know that the following character (") should be considered part of the string, and not part of the line's syntax.

I tried using the same logic / escape character in SAS, and it does not appear to work. If anyone could inform me how to use special characters in a string (like a double or single quotation mark), I would greatly appreciate it!!

Thank you :)
 
Try single quotes. I.e.

a_new_string = 'John said, "How are you?"';

I'm not at work though so couldn't test that, but I think that's how you would do it.
 
Yup, that's the way you do it. Use the other style of quotes to wrap the test string.
If the text string is too complicated for this (ie containing both styles of quotes) you have 2 options.
1 - break it down into smaller strings and concatenate the results.
2 - look into the %quote and %nquote macro functions, I believe that they have some functionality that might help you out.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top