QUOTE Function

Adds double quotation marks to a character value.

Category: Character
Returned data type: NCHAR

Syntax

QUOTE(expression)

Arguments

expression

specifies any valid expression that evaluates to a character string.

Data type NCHAR
See <sql-expression>
FedSQL Expressions

Details

The QUOTE function adds double quotation marks, the default character, to a character value. If double quotation marks are found within the argument, they are doubled in the output.
The length of the receiving variable must be long enough to contain the argument (including trailing blanks), leading and trailing quotation marks, and any embedded quotation marks that are doubled. For example, if the argument is ABC followed by three trailing blanks, then the receiving variable must have a length of at least eight to hold “ABC###”. (The character # represents a blank space.) If the receiving field is not long enough, the QUOTE function returns a blank string, and writes an invalid argument note to the SAS log.
A string of characters enclosed in double quotation marks is a DS2 identifier and not a character constant. The double quotation marks become part of the identifier. Quoted identifiers cannot be used to create column names in an output table.

Example

The following statements illustrate the QUOTE function:
Statements
Results
select quote('A"B');
"A""B"
select quote('A''B');
"A'B"
select quote('Paul''s Catering Service');
"Paul's Catering Service"
Last updated: February 23, 2017