Previous Page | Next Page

Functions and CALL Routines

DEQUOTE Function



Removes matching quotation marks from a character string that begins with a quotation mark, and deletes all characters to the right of the closing quotation mark.
Category: Character
Restriction: I18N Level 2

Syntax
Arguments
Details
Length of Returned Variable
The Basics
Examples

Syntax

DEQUOTE(string)


Arguments

string

specifies a character constant, variable, or expression.


Details


Length of Returned Variable

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 Basics

The value that is returned by the DEQUOTE function is determined as follows:

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]


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                     

Previous Page | Next Page | Top of Page