<?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: creating Dynamic SQL in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669068#M200664</link>
    <description>You mean we have to assign with double quotes macro variables . effective date is having dates converting into characters because I will be passing dates with [ ] in pivot sql function&lt;BR /&gt;&lt;BR /&gt;This SQL perfectly working in sql server but not SAS</description>
    <pubDate>Tue, 14 Jul 2020 02:56:31 GMT</pubDate>
    <dc:creator>Ashpak</dc:creator>
    <dc:date>2020-07-14T02:56:31Z</dc:date>
    <item>
      <title>creating Dynamic SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/668980#M200619</link>
      <description>&lt;P&gt;Hi Team&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have Dynamic SQL with Pivot Functionality , could you please help how to create this PROC SQL&lt;/P&gt;&lt;P&gt;here is my code which runs in SQL server. Same SQL code I need to use in&lt;/P&gt;&lt;P&gt;PROC SQL procedure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;DECLARE&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; @Effdt &lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;NVARCHAR&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;(&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#ff00ff"&gt;MAX&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;)&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#808080"&gt;=&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#ff0000"&gt;''&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;DECLARE&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; @Query &lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;NVARCHAR&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;(&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#ff00ff"&gt;MAX&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;)&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#808080"&gt;=&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#ff0000"&gt;''&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; @Effdt &lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;+=&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#808080"&gt;+&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#ff00ff"&gt;QUOTENAME&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;(&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;eff_dt&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;)+&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#ff0000"&gt;','&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;FROM&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;SELECT&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#0000ff"&gt;DISTINCT&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; eff_dt&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; [reference]&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;.&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;[AL_ALM_RATE_INDEX] &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;)&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#0000ff"&gt;AS&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; eff_dt&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;SET&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; @Effdt &lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;=&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#808080"&gt;LEFT(&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;@Effdt&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;,&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#ff00ff"&gt;LEN&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;(&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;@Effdt&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;)-&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--print @Effdt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Set&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; @Query&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;=&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#ff0000"&gt;' select * from &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;select data_point, EFF_DT,RATE_INDEX,RATE_INDEX_NAME from [reference].[AL_ALM_RATE_INDEX]&lt;/P&gt;&lt;P&gt;where len(RATE_INDEX_NAME)&amp;gt;0 and RATE_INDEX_NAME not like ''FTP_%''&lt;/P&gt;&lt;P&gt;)a&lt;/P&gt;&lt;P&gt;pivot&lt;/P&gt;&lt;P&gt;( max(RATE_INDEX)&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#ff0000"&gt;for EFF_DT in ('&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;+&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;@Effdt&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#808080"&gt;+&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#ff0000"&gt;') &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;)pivts'&lt;/P&gt;&lt;P&gt;--PRINT @Query&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;EXECUTE&lt;/FONT&gt; &lt;FONT face="Consolas" size="2" color="#800000"&gt;sp_executesql&lt;/FONT&gt; &lt;FONT face="Consolas" size="2"&gt;@Query&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 21:25:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/668980#M200619</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2020-07-13T21:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: creating Dynamic SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/668984#M200621</link>
      <description>Can you use explicit SQL Pass through?</description>
      <pubDate>Mon, 13 Jul 2020 21:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/668984#M200621</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-13T21:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: creating Dynamic SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/668985#M200622</link>
      <description>&lt;P&gt;I'm new to SAS ,&lt;/P&gt;&lt;P&gt;Could you please help with me that how to use explicit SQL in SAS?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 21:37:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/668985#M200622</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2020-07-13T21:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: creating Dynamic SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/668997#M200630</link>
      <description>&lt;P&gt;This documentation will help:&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=acreldb&amp;amp;docsetTarget=p09s44hpea09stn1puyx1l5vcwwt.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;SQL Pass-Through Facility Specifics for Microsoft SQL Server&lt;/A&gt;&amp;nbsp;. However, without knowing your specific SAS environment, it's going to be difficult to assist you without more information from you. Are you running a local version of SAS, or in a server/grid environment? If a server environment, how is authentication to SQL Server handled in your environment?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 22:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/668997#M200630</guid>
      <dc:creator>ketpt42</dc:creator>
      <dc:date>2020-07-13T22:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: creating Dynamic SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669004#M200633</link>
      <description>&lt;P&gt;You can use pass through, which lets you pass your SQL commands directly to the server.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.lexjansen.com/sesug/2017/DM-57.pdf" target="_blank"&gt;https://www.lexjansen.com/sesug/2017/DM-57.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to migrate this code to SAS, that's a different task and you'll likely want to switch this out of SQL and use either a data step or macro language.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UCLA introductory tutorial on macro variables and macros&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Examples of common macro usage&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 22:30:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669004#M200633</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-13T22:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: creating Dynamic SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669015#M200642</link>
      <description>&lt;P&gt;thanks&amp;nbsp; tried this way giving error now&lt;/P&gt;&lt;P&gt;51 EXECUTE sp_executesql &amp;amp;Query&lt;/P&gt;&lt;P&gt;52 ) by odbc;&lt;/P&gt;&lt;P&gt;ERROR: CLI execute error: [Microsoft][SQL Server Native Client 11.0][SQL Server]'nvarchar' is not a recognized built-in function&lt;/P&gt;&lt;P&gt;name. : [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near '('. : [Microsoft][SQL Server Native&lt;/P&gt;&lt;P&gt;Client 11.0][SQL Server]Incorrect syntax near 'max'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;code&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Effdt nvarchar(max)='';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Query nvarchar(max)='';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;connect&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; odbc(DSN=CALM_HUB_PRD user=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"AD-ENT\aaaa"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; password=&amp;amp;pwds);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;execute&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;SELECT &amp;amp;Effdt += + QUOTENAME(eff_dt)+ &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;','&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;SELECT DISTINCT eff_dt&lt;/P&gt;&lt;P&gt;FROM CALM_HUB.reference.AL_ALM_RATE_INDEX&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;SET &amp;amp;Effdt = LEFT(&amp;amp;Effdt, LEN(&amp;amp;Effdt)-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SET &amp;amp;Query=&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'select * from &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;select data_point, EFF_DT,RATE_INDEX,RATE_INDEX_NAME from [reference].[AL_ALM_RATE_INDEX]&lt;/P&gt;&lt;P&gt;where len(RATE_INDEX_NAME)&amp;gt;0 and RATE_INDEX_NAME not like ''FTP_%''&lt;/P&gt;&lt;P&gt;)a&lt;/P&gt;&lt;P&gt;pivot&lt;/P&gt;&lt;P&gt;( max(RATE_INDEX)&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;for EFF_DT in ('&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;Effdt+&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;') &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;)pivts'&lt;/P&gt;&lt;P&gt;EXECUTE sp_executesql &amp;amp;Query&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; odbc;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 23:23:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669015#M200642</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2020-07-13T23:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: creating Dynamic SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669062#M200662</link>
      <description>Well you didn't pass in any dates and macro variables only resolve in double quotes.</description>
      <pubDate>Tue, 14 Jul 2020 02:25:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669062#M200662</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-14T02:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: creating Dynamic SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669068#M200664</link>
      <description>You mean we have to assign with double quotes macro variables . effective date is having dates converting into characters because I will be passing dates with [ ] in pivot sql function&lt;BR /&gt;&lt;BR /&gt;This SQL perfectly working in sql server but not SAS</description>
      <pubDate>Tue, 14 Jul 2020 02:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669068#M200664</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2020-07-14T02:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: creating Dynamic SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669070#M200665</link>
      <description>Are you submitting the exact same code? I suspect not so compare your log to your submitted code to see how it differs.</description>
      <pubDate>Tue, 14 Jul 2020 03:06:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669070#M200665</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-14T03:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: creating Dynamic SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669347#M200779</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/337616"&gt;@Ashpak&lt;/a&gt;&amp;nbsp; - From what I see in your original query you don't need to define SAS macro variables as these are declared SQL variables and you need to add your SQL DECLARE statements back in. You should be able to simply copy and paste your original SQL Server code into the SAS EXECUTE statement. Maybe you could start with a simple test like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   connect to odbc (noprompt = "server=MySQLServer;DRIVER=SQL Server Native Client 11.0;Trusted_Connection=yes;"); 
   execute (delete from [MyDatabase].[MySchema].[MyTable]
           ) by ODBC;
   disconnect from ODBC;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please note EXECUTE does not support reading a result set from the SQL processing. If your SQL code produces a result set then you will need to insert that into an SQL Server temporary table, then query that with a separate SELECT * from connection to ODBC statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 01:15:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-Dynamic-SQL-in-SAS/m-p/669347#M200779</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-07-15T01:15:53Z</dc:date>
    </item>
  </channel>
</rss>

