DEQUOTE Function


Removes matching quotation marks from a character string that begins with an individual quotation mark and deletes everything that is to the right of the closing quotation mark

Category: Character

Syntax

DEQUOTE ( string )

Arguments

string

  • specifies a character constant, variable, or expression.

Details

If the DEQUOTE function returns a value to a variable that has not yet been assigned a length, then by default the variable length is determined by the length of the first argument.

The value that is returned by the DEQUOTE function depends on the first character or the first two characters in string :

  • If the first character of string is not a single or double quotation mark, DEQUOTE returns string unchanged.

  • If the first two characters of string are both single quotation marks or both double quotation marks, DEQUOTE returns a result with a length of zero.

  • If the first character of string is a single quotation mark, the DEQUOTE function removes that single quotation mark from the result. DEQUOTE then scans string from left to right, looking for more single quotation marks. All paired single quotation marks are reduced to one single quotation mark. The first non-paired single quotation mark in string is removed and all characters to the right of that quotation mark are also removed.

  • If the first character of string is a double quotation mark, the DEQUOTE function removes that double quotation mark from the result. DEQUOTE then scans string from left to right, looking for more double quotation marks. All paired double quotation marks are reduced to one double quotation mark. The first non-paired double quotation mark in string is removed and all characters to the right of that quotation mark are also removed.

Note: If string is a constant enclosed by quotation marks, those quotation marks are not part of the value of string . Therefore, you do not need to use DEQUOTE to remove the quotation marks that denote a constant.

Examples

This example demonstrates the use of DEQUOTE within a DATA step.

 data test;     input string .;     result = dequote(string);     datalines;  No quotes, no change  No "leading" quote, no change  "" returns a string with length zero  "Matching double quotes are removed"  'Matching single quotes are removed'  "Paired ""quotes"" are reduced"  'Paired '' quotes'' are reduced'  "Single 'quotes' inside '' double'' quotes are unchanged"  'Double "quotes" inside ""single"" quotes are unchanged'  "No matching quote, no problem  Don't remove this apostrophe  "Text after the matching quote" is "deleted"  ;  proc print noobs;  title 'Input Strings and Output Results from DEQUOTE';  run; 
Output 4.23: Removing Matching Quotation Marks with the DEQUOTE Function
start example
 Input Strings and Output Results from DEQUOTE               1  string  No quotes, no change  No "leading" quote, no change  "" returns a string with length zero  "Matching double quotes are removed"  'Matching single quotes are removed'  "Paired ""quotes"" are reduced"  'Paired '' quotes'' are reduced'  "Single 'quotes' inside '' double'' quotes are unchanged"  'Double "quotes" inside ""single"" quotes are unchanged'  "No matching quote, no problem  Don't remove this apostrophe  "Text after the matching quote" is "deleted"  result  No quotes, no change  No "leading" quote, no change  Matching double quotes are removed  Matching single quotes are removed  Paired "quotes" are reduced  Paired ' quotes' are reduced  Single 'quotes' inside '' double'' quotes are unchanged  Double "quotes" inside ""single"" quotes are unchanged  No matching quote, no problem  Don't remove this apostrophe  Text after the matching quote 
end example
 



SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net