Previous Page | Next Page

Data Set Options for Relational Databases

ESCAPE_BACKSLASH= Data Set Option



Specifies whether backslashes in literals are preserved during data copy from a SAS data set to a table.
Default value: NO
Valid in: DATA and PROC steps (when accessing DBMS data using SAS/ACCESS software)
DBMS support: MySQL

Syntax
Syntax Description
Details
Example
See Also

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.


Example

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\\')

If ESCAPE_BACKSLASH=NO instead in this example, this error displays:

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


See Also

To assign this option to a group of relational DBMS tables or views, see the ESCAPE_BACKSLASH= LIBNAME Option.

Previous Page | Next Page | Top of Page