| Functions and CALL Routines | 
| Category: | Character | 
| Restriction: | I18N Level 2 | 
| Syntax | |
| Arguments | |
| Details | |
| Length of Returned Variable | |
| The Basics | |
| Examples | |
Syntax | 
| DEQUOTE(string) | 
| Details | 
In a DATA step, if the DEQUOTE function returns a value to a variable that has not been previously assigned a length, then that variable is given the length of the argument.
The value that is returned by the DEQUOTE function is determined as follows:
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, and the third character is not the same type of quotation mark, then 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. Each pair of consecutive, single quotation marks is reduced to one single quotation mark. The first single quotation mark that does not have an ending 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. Each pair of consecutive, double quotation marks is reduced to one double quotation mark. The first double quotation mark that does not have an ending 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.  ![[cautionend]](../../../../common/63294/HTML/default/images/cautend.gif)
| Examples | 
This example demonstrates the use of DEQUOTE within a DATA step.
options pageno=1 nodate ls=80 ps=64; data test; input string $60.; result = dequote(string); datalines; No quotation marks, no change No "leading" quotation marks, no change "Matching double quotation marks are removed" 'Matching single quotation marks are removed' "Paired ""quotation marks"" are reduced" 'Paired '' quotation marks '' are reduced' "Single 'quotation marks' inside '' double'' quotation marks are unchanged" 'Double "quotation marks" inside ""single"" quotation marks are unchanged' "No matching quotation mark, no problem Don't remove this apostrophe "Text after the matching quotation mark" is "deleted" ; proc print noobs; title 'Input Strings and Output Results from DEQUOTE'; run;
Removing Matching Quotation Marks with the DEQUOTE Function
                 Input Strings and Output Results from DEQUOTE                 1
          string
          No quotation marks, no change                               
          No "leading" quotation marks, no change                     
          "Matching double quotation marks are removed"               
          'Matching single quotation marks are removed'               
          "Paired ""quotation marks"" are reduced"                    
          'Paired '' quotation marks '' are reduced'                  
          "Single 'quotation marks' inside '' double'' quotation marks
          'Double "quotation marks" inside ""single"" quotation marks 
          "No matching quotation mark, no problem                     
          Don't remove this apostrophe                                
          "Text after the matching quotation mark" is "deleted"       
          result
          No quotation marks, no change                              
          No "leading" quotation marks, no change                    
          Matching double quotation marks are removed                
          Matching single quotation marks are removed                
          Paired "quotation marks" are reduced                       
          Paired ' quotation marks ' are reduced                     
          Single 'quotation marks' inside '' double'' quotation marks
          Double "quotation marks" inside ""single"" quotation marks 
          No matching quotation mark, no problem                     
          Don't remove this apostrophe                               
          Text after the matching quotation mark                     
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.