<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro Quoting DB2-Command (SQL-Pass Through) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quoting-DB2-Command-SQL-Pass-Through/m-p/578618#M164130</link>
    <description>&lt;P&gt;Single quotes prevent the resolution of macro variables. Use double quotes for strings with macro variables.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Aug 2019 05:47:53 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-08-02T05:47:53Z</dc:date>
    <item>
      <title>Macro Quoting DB2-Command (SQL-Pass Through)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quoting-DB2-Command-SQL-Pass-Through/m-p/578615#M164127</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting an error message, when trying to execute a DB2-command via pass-through. The problem seems to be, that my macro variable is not being resolved during compilation/execution?&lt;/P&gt;&lt;P&gt;I am pretty sure, the issue at hand is macro quoting. But I do not know what function (%STR(), %QUOTE(), %SUPERQ(), etc.) to use. Here is the error return code of the database:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ERROR: CLI execute error: [IBM][CLI Driver][DB2/AIX64] SQL2306N The table or index "SCHEMA1.&amp;amp;DB2_TBL_NAME" does not exist.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody give me a hint, on how to write the code properly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is, what I got as of now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let DB2_TBL_NAME  = Table1;

proc sql;
connect to db2 (database=sas AUTHDOMAIN="DB2Auth");
 EXECUTE( CALL SYSPROC.ADMIN_CMD( 'RUNSTATS ON TABLE SCHEMA1.&amp;amp;DB2_TBL_NAME ON ALL COLUMNS WITH DISTRIBUTION ON ALL COLUMNS AND SAMPLED DETAILED INDEXES ALL SET PROFILE' ))by db2; 
disconnect from db2; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank's in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 05:35:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quoting-DB2-Command-SQL-Pass-Through/m-p/578615#M164127</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2019-08-02T05:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Quoting DB2-Command (SQL-Pass Through)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quoting-DB2-Command-SQL-Pass-Through/m-p/578618#M164130</link>
      <description>&lt;P&gt;Single quotes prevent the resolution of macro variables. Use double quotes for strings with macro variables.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 05:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quoting-DB2-Command-SQL-Pass-Through/m-p/578618#M164130</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-02T05:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Quoting DB2-Command (SQL-Pass Through)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quoting-DB2-Command-SQL-Pass-Through/m-p/578620#M164132</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wish, I could, but the DB2-command, does not allow for double quotation marks. Therefore "I am forced" to use singe quotation marks....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With double qoutes, I get this error from DB2:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ERROR: CLI execute error: [IBM][CLI Driver][DB2/AIX64] SQL0107N The name "RUNSTATS ON TABLE SCHEMA1.Table1&lt;BR /&gt;ON ALL COL" is too long. The maximum length is "128". SQLSTATE=42622&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The issue is NOT, that my command is too long. It is the double quotation marks, that DB2 does not like...&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 05:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quoting-DB2-Command-SQL-Pass-Through/m-p/578620#M164132</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2019-08-02T05:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Quoting DB2-Command (SQL-Pass Through)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quoting-DB2-Command-SQL-Pass-Through/m-p/578622#M164133</link>
      <description>&lt;P&gt;You can try using %BQUOTE().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let DB2_TBL_NAME  = Table1;

proc sql;
connect to db2 (database=sas AUTHDOMAIN="DB2Auth");
 EXECUTE( CALL SYSPROC.ADMIN_CMD(
%bquote('RUNSTATS ON TABLE SCHEMA1.&amp;amp;DB2_TBL_NAME ON ALL COLUMNS WITH DISTRIBUTION ON ALL COLUMNS AND SAMPLED DETAILED INDEXES ALL SET PROFILE' )
))by db2; 
disconnect from db2; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or make the whole quoted string as a macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let DB2_TBL_NAME  = Table1;
%let cmd=%sysfunc(quote(
RUNSTATS ON TABLE SCHEMA1.&amp;amp;DB2_TBL_NAME 
ON ALL COLUMNS 
WITH DISTRIBUTION ON ALL COLUMNS 
AND SAMPLED DETAILED INDEXES ALL 
SET PROFILE,%str(%')));

proc sql;
  connect to db2 (database=sas AUTHDOMAIN="DB2Auth");
  EXECUTE( CALL SYSPROC.ADMIN_CMD(&amp;amp;cmd))by db2; 
  disconnect from db2; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Aug 2019 06:18:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quoting-DB2-Command-SQL-Pass-Through/m-p/578622#M164133</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-02T06:18:09Z</dc:date>
    </item>
  </channel>
</rss>

