ESCAPE_BACKSLASH= Data Set Option

Specifies whether backslashes in literals are preserved during data copy from a SAS data set to a table.
Valid in: DATA and PROC steps (when accessing DBMS data using SAS/ACCESS software)
Default: NO
Data source: MySQL
See: ESCAPE_BACKSLASH= LIBNAME option

Syntax

ESCAPE_BACKSLASH=YES | NO

Syntax Description

YES
specifies that an additional backslash is inserted in every literal value that already contains a backslash.
NO
specifies that backslashes that exist in literal values are not preserved. An error results.

Details

MySQL uses the backslash as an escape character. When data that is copied from a SAS data set to a MySQL table contains backslashes in literal values, the MySQL interface can preserve them if ESCAPE_BACKSLASH=YES.

Examples

Example 1: Preserve Backslashes

In this example, SAS preserves the backslashes for x and y values.
libname out mysql user=dbitest pw=dbigrp1
        server=striper database=test port=3306;
data work.test;
   length x y z $10;
   x = "ABC";
   y = "DEF\";
   z = 'GHI\';
run;
data out.test(escape_backslash=yes);
set work.test;
run;
The code successfully generates this INSERT statement.
INSERT INTO 'test' ('x','y','z')  VALUES ('ABC','DEF\\','GHI\\')

Example 2: Use the Default Value (Do Not Preserve Backslashes)

For the prior example, here is the error that is displayed if ESCAPE_BACKSLASH=NO.
ERROR: Execute error: You have an error in your SQL syntax; 
check the manual that corresponds to your MySQL server version for the 
right syntax to use near 'GHI\')' at line 1