$QUOTEw. Format

Writes data values that are enclosed in single quotation marks.

Category: Character
Alignment: Left

Syntax

$QUOTEw.

Arguments

w

specifies the width of the output field.

Default 2 if the length of the variable is undefined; otherwise, the length of the variable + 2.
Range 2–32767
Tip Make w wide enough to include the left and right quotation marks.

Details

When you use the $QUOTEw. format, all literals must be in single quotation marks.
The following list describes the output that SAS produces when you use the $QUOTEw. format.
  • If your data value is not enclosed in quotation marks, SAS encloses the output in double quotation marks.
  • If your data value is not enclosed in quotation marks, but the value contains a single quotation mark, SAS takes the following actions:
    • encloses the data value in double quotation marks
    • does not change the single quotation mark.
  • If your data value begins and ends with single quotation marks, and the value contains double quotation marks, SAS takes the following actions:
    • encloses the data value in double quotation marks
    • duplicates the double quotation marks that are found in the data value
    • does not change the single quotation marks.
  • If your data value begins and ends with single quotation marks, and the value contains two single contiguous quotation marks, SAS takes the following actions:
    • encloses the value in double quotation marks
    • does not change the single quotation marks.
  • If your data value begins and ends with single quotation marks, and contains both double quotation marks and single, contiguous quotation marks, SAS takes the following actions:
    • encloses the value in double quotation marks
    • duplicates the double quotation marks that are found in the data value
    • does not change the single quotation marks.
  • If the length of the target field is not large enough to contain the string and its quotation marks, SAS returns all blanks.

Example

Statements
Results
----+----1----+----2
select put('SAS',$quote.);
"SAS"
select put('SAS''s',$quote.);
"SAS's"
select put('ad''verb',$quote16.);
"ad'verb"
select put('"ad"''"verb"',$quote20.);
"""ad""'""verb"""
Last updated: February 23, 2017