<?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: SQL Pass Through in macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394672#M95129</link>
    <description>&lt;P&gt;Difficult to know what is not working without seeing the log with option symbolgen, mprint and mlogic active.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You don't call the macro GEN in the posted code, but the macro proc19_1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Sep 2017 13:32:57 GMT</pubDate>
    <dc:creator>error_prone</dc:creator>
    <dc:date>2017-09-11T13:32:57Z</dc:date>
    <item>
      <title>SQL Pass Through in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394665#M95128</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What might be the reason&amp;nbsp; sas do not the run Macro with Pass Throught while the same statment out of macro is working properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for instance:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Macro GEN(x_date);

%let Krok=&amp;amp;sysmacroname;
%let sql_x_d=%sysfunc(putn("&amp;amp;x_date"d, YYMMDD.));
%let sql_x_date=%unquote(%str(%'&amp;amp;sql_x_d%'));
%macro_start;


%do i=1 %to 12;



%if &amp;amp;i&amp;lt;12 %then %do;
%let a=1;
%end;
%else %do;
%let a=0;
%end;


proc sql;    
   connect to oracle (user=pass password=pass path=pass); 
   create table proc19_1 as
      select * 
         from connection to oracle       
            (select 
				time_stamp
				id_cst
				id_trans
				ofer_kg
				rate_kg
			from hd.customers 
			where time_stampt between    &lt;BR /&gt;                            last_day(add_months(to_date(&amp;amp;sql_x_date),%eval(-&amp;amp;i)))-&amp;amp;a &lt;BR /&gt;                            and last_day(add_months(to_date(&amp;amp;sql_x_date),%eval(-&amp;amp;i+1)))

		disconnect from oracle; 
quit;



%proc19_1;


%end;





%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 13:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394665#M95128</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-09-11T13:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass Through in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394672#M95129</link>
      <description>&lt;P&gt;Difficult to know what is not working without seeing the log with option symbolgen, mprint and mlogic active.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You don't call the macro GEN in the posted code, but the macro proc19_1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 13:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394672#M95129</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-09-11T13:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass Through in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394675#M95130</link>
      <description>I ve called macro GEN, however did`t post it here, even if I exclude macro proc19_1 is the same, after calling macro nothing happend even log stay empty, I am working on EG.</description>
      <pubDate>Mon, 11 Sep 2017 13:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394675#M95130</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-09-11T13:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass Through in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394677#M95131</link>
      <description>&lt;P&gt;What is your question? Did you get any error? Please post the log.&lt;/P&gt;
&lt;P&gt;You do not appear to be calling your macro anywhere in the code you posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your pass through SQL code is missing commas and your CREATE TABLE statement is missing a semi-colon.&lt;/P&gt;
&lt;P&gt;You don't need all of those %EVAL() in the middle of the SQL code. I am pretty sure that Oracle can figure out how to add 1 to -5 on its own.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to oracle (user=pass password=pass path=pass);
create table proc19_1 as
  select *
     from connection to oracle
    (select time_stamp
          , id_cst
          , id_trans
          , ofer_kg
          , rate_kg
     from hd.customers
     where time_stampt
      between last_day(add_months(to_date(&amp;amp;sql_x_date),-&amp;amp;i-&amp;amp;a))
      and last_day(add_months(to_date(&amp;amp;sql_x_date),-&amp;amp;i+1))
     )
;
disconnect from oracle; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 13:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394677#M95131</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-11T13:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass Through in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394685#M95133</link>
      <description>&lt;P&gt;I see two %macro definitions, but only one corresponding %mend.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post &lt;EM&gt;complete&lt;/EM&gt; code and log.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 14:01:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/394685#M95133</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-09-11T14:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass Through in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/395290#M95288</link>
      <description>&lt;P&gt;Ok, thanks I found mistakes by running code in SQLDeveloper, however, it`s strange that when I tried run code with my mistakes in SAS, I keep received blank log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2017 20:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/395290#M95288</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-09-12T20:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass Through in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/395382#M95333</link>
      <description>&lt;P&gt;As long as you have an unfinished macro definition, no code will run, and therefore no meaningful log will be produced.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 05:01:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/395382#M95333</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-09-13T05:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass Through in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/396179#M95617</link>
      <description>There are finished macros defintion,&lt;BR /&gt;you ve got 2 macros trigger by the posted macro:&lt;BR /&gt;%macro_start;&lt;BR /&gt;and&lt;BR /&gt;%proc19_1;</description>
      <pubDate>Fri, 15 Sep 2017 07:11:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/396179#M95617</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-09-15T07:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass Through in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/396181#M95618</link>
      <description>&lt;P&gt;In the &lt;U&gt;code you posted&lt;/U&gt;, there are two (2) %macro statements that start a macro definition, but there is only one (1) %mend, so one of the macro definitions is still pending, causing no code to be run.&lt;/P&gt;
&lt;P&gt;BTW don't do nested macro definitions. SAS keeps all macros in the global scope, so nesting them just complicates your code and makes it less maintainable, but serves no purpose (apart from confusing the programmer).&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 07:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-Through-in-macro/m-p/396181#M95618</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-09-15T07:20:56Z</dc:date>
    </item>
  </channel>
</rss>

