$QUOTEw. Format

Writes data values that are enclosed in double quotation marks.
Category: Character
Alignment: left

Syntax

$QUOTEw.

Syntax Description

w
specifies the width of the output field.
Default:2, if the length of the variable is undefined. Otherwise, the default is the length of the variable + 2
Range:2–32767
Tip:Make w wide enough to include the left and right quotation marks.

Details

The following list describes the output that SAS produces when you use the $QUOTEw. format. For examples of these items, see the examples below.
  • 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 does the following:
    • 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 does the following:
    • 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 does the following:
    • 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 does the following:
    • 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 as much of the quoted string that will fit in the field.

Example

put name $quote20.;
Value of name
Result
----+----1----+----2
SAS
"SAS"
SAS's
"SAS's"
'ad"verb"'
"'ad""verb""'"
'ad''verb'
"'ad''verb'"
 
'"ad"''"verb"'
----+----1----+----2
"'""ad""''""verb""'"
deoxyribonucleotide
"deoxyribonucleotid" 1
1deoxyribonucleotide is 19 characters. When SAS adds the quotation marks, the length of the string is 21 characters. SAS truncates the letter e at the end of the text to accommodate the quotation marks.