<?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: Proc SQL with condition  insert in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721126#M27766</link>
    <description>Oddly enough wasn't missing the first time....</description>
    <pubDate>Mon, 22 Feb 2021 23:05:12 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-02-22T23:05:12Z</dc:date>
    <item>
      <title>Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721089#M27758</link>
      <description>I would like use something below like this&lt;BR /&gt;If cntr below value &amp;gt;0 then I would like to use insert operation how to do this SAS&lt;BR /&gt;&lt;BR /&gt;Proc SQL;&lt;BR /&gt;Select count(*) into :cntr from abc :&lt;BR /&gt;%put &amp;amp;cntr;&lt;BR /&gt;Run:&lt;BR /&gt;Proc SQL ;&lt;BR /&gt;If cntr&amp;gt;0 then&lt;BR /&gt;Do;&lt;BR /&gt;Insert into xyz&lt;BR /&gt;Select from gggg&lt;BR /&gt;</description>
      <pubDate>Mon, 22 Feb 2021 21:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721089#M27758</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2021-02-22T21:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721097#M27759</link>
      <description>&lt;P&gt;You would use macro logic in this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if  %eval(&amp;amp;cntr &amp;gt; 0) %then %do;

%put "In IF condition";

proc sql;
insert .......

Quit;

%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;General rule, is first make sure your code works then make sure your macro works.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I usually just use a %PUT statement to be able to verify my logic as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some macro references for you, if this is a new topic:&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;Tutorial on converting a working program to a macro&lt;BR /&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/337616"&gt;@Ashpak&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I would like use something below like this&lt;BR /&gt;If cntr below value &amp;gt;0 then I would like to use insert operation how to do this SAS&lt;BR /&gt;&lt;BR /&gt;Proc SQL;&lt;BR /&gt;Select count(*) into :cntr from abc :&lt;BR /&gt;%put &amp;amp;cntr;&lt;BR /&gt;Run:&lt;BR /&gt;Proc SQL ;&lt;BR /&gt;If cntr&amp;gt;0 then&lt;BR /&gt;Do;&lt;BR /&gt;Insert into xyz&lt;BR /&gt;Select from gggg&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 21:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721097#M27759</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-22T21:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721114#M27760</link>
      <description>&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;I tried this way.&lt;/STRONG&gt;&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;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; count(*) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; :cntr &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NVPLocal.NVP_DOD_Catch ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;cntr;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; qrm_db,strategy,moddate format=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Date9.&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; :Var1,:Var2,:Var3 &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NVPLocal.NVP_DOD_Catch ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&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" color="#000080"&gt;&lt;STRONG&gt;%Macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;getit&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%if&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;cntr &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%do&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" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; "In IF condition";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;insert into NVPLocal.NVP_PRICING_HIS&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;select * from FASTControl]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[dbo]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[ALM_NVPData] &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;where qrm_db=&amp;amp;Var1&lt;/P&gt;&lt;P&gt;and strategy=&amp;amp;Var2&lt;/P&gt;&lt;P&gt;and moddate=&amp;amp;Var3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%Mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; getit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;getit&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;getting error :&lt;/P&gt;&lt;P&gt;here were 1 unclosed %DO statements. The macro GETIT will not be compiled.&lt;/P&gt;&lt;P&gt;ERROR: A dummy macro will be compiled.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 22:29:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721114#M27760</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2021-02-22T22:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721116#M27761</link>
      <description>&lt;P&gt;&lt;STRONG&gt;here were 1 unclosed %DO statements.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Where's the %END to end your %DO? You do not need to wrap that code within a macro, that's an older requirement, using it inline like I suggested will work with newer versions of SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/337616"&gt;@Ashpak&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;I tried this way.&lt;/STRONG&gt;&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;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; count(*) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; :cntr &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NVPLocal.NVP_DOD_Catch ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;cntr;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; qrm_db,strategy,moddate format=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Date9.&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; :Var1,:Var2,:Var3 &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NVPLocal.NVP_DOD_Catch ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&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" color="#000080"&gt;&lt;STRONG&gt;%Macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;getit&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%if&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;cntr &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%do&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" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; "In IF condition";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;insert into NVPLocal.NVP_PRICING_HIS&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;select * from FASTControl]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[dbo]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[ALM_NVPData] &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;where qrm_db=&amp;amp;Var1&lt;/P&gt;
&lt;P&gt;and strategy=&amp;amp;Var2&lt;/P&gt;
&lt;P&gt;and moddate=&amp;amp;Var3;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Quit;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%Mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; getit;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;getit&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;getting error :&lt;/P&gt;
&lt;P&gt;here were 1 unclosed %DO statements. The macro GETIT will not be compiled.&lt;/P&gt;
&lt;P&gt;ERROR: A dummy macro will be compiled.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 22:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721116#M27761</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-22T22:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721118#M27762</link>
      <description>proc sql;&lt;BR /&gt;select count(*) into :cntr from NVPLocal.NVP_DOD_Catch ;&lt;BR /&gt;%put &amp;amp;cntr;&lt;BR /&gt;&lt;BR /&gt;select qrm_db,strategy,moddate format=Date9. into :Var1,:Var2,:Var3 from NVPLocal.NVP_DOD_Catch ;&lt;BR /&gt;run;&lt;BR /&gt;%macro getit&lt;BR /&gt;%if %eval(&amp;amp;cntr &amp;gt; 0) %then %do;&lt;BR /&gt;%put "In IF condition";&lt;BR /&gt;proc sql;&lt;BR /&gt;insert into NVPLocal.NVP_PRICING_HIS&lt;BR /&gt;select * from FASTControl].[dbo].[ALM_NVPData]&lt;BR /&gt;where qrm_db=&amp;amp;Var1&lt;BR /&gt;and strategy=&amp;amp;Var2&lt;BR /&gt;and moddate=&amp;amp;Var3;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%getit;&lt;BR /&gt;&lt;BR /&gt;error message&lt;BR /&gt;ERROR: Expected semicolon not found. The macro will not be compiled.&lt;BR /&gt;ERROR: A dummy macro will be compiled.</description>
      <pubDate>Mon, 22 Feb 2021 22:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721118#M27762</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2021-02-22T22:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721120#M27763</link>
      <description>&lt;P&gt;ERROR: Expected semicolon not found. The macro will not be compiled.&lt;/P&gt;&lt;P&gt;ERROR: A dummy macro will be compiled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; count(*) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; :cntr &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NVPLocal.NVP_DOD_Catch ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;cntr;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; qrm_db,strategy,moddate format=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Date9.&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; :Var1,:Var2,:Var3 &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NVPLocal.NVP_DOD_Catch ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&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" color="#000080"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;getit&lt;/I&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%if&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;cntr &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%do&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" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; "In IF condition";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;insert into NVPLocal.NVP_PRICING_HIS&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;select * from FASTControl]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[dbo]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[ALM_NVPData] &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;where qrm_db=&amp;amp;Var1&lt;/P&gt;&lt;P&gt;and strategy=&amp;amp;Var2&lt;/P&gt;&lt;P&gt;and moddate=&amp;amp;Var3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%end&lt;/FONT&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;%&lt;STRONG&gt;&lt;I&gt;getit&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 22:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721120#M27763</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2021-02-22T22:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721124#M27765</link>
      <description>&lt;P&gt;You are missing a semicolon on this statement:%macro getit&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 23:03:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721124#M27765</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-02-22T23:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721126#M27766</link>
      <description>Oddly enough wasn't missing the first time....</description>
      <pubDate>Mon, 22 Feb 2021 23:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721126#M27766</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-22T23:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721134#M27768</link>
      <description>&lt;P&gt;yes my bad missed out, Thanks for your help&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 23:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721134#M27768</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2021-02-22T23:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721426#M27789</link>
      <description>&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;This macro is failing while executing getting error message &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ERROR: Expression using greater than or equal (&amp;gt;=) has components that are of different data types.&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;_null_&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" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symputx(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'today'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,quote(put(today(),&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;yymmdd10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;),&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"'"&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" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&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" 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;create&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NVPLocal.tmp &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;as&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;select&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;distinct&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; qrm_db,strategy,moddate &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NVPLocal.NVP_DOD_Catch; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; count(*) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; :cntr1 &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NVPLocal.tmp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;quit&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;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;getit&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;cntr1 &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;insert into NVPLocal.NVP_PRICING_HIS&lt;/P&gt;&lt;P&gt;select &amp;amp;today, * from NVPLocal.temp&lt;/P&gt;&lt;P&gt;where qrm_db=&amp;amp;Var1&lt;/P&gt;&lt;P&gt;and strategy=&amp;amp;Var2&lt;/P&gt;&lt;P&gt;and moddate&amp;gt;=&amp;amp;Var3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%end&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" color="#000080"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%getit;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 23:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721426#M27789</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2021-02-23T23:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721591#M27795</link>
      <description>Show the equivalent code that works without macros. &lt;BR /&gt;Since the error indicates a mistmatch of data types around an equality sign it's likely an issue with your WHERE condition - do you need quotes around one of the variables?</description>
      <pubDate>Wed, 24 Feb 2021 15:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/721591#M27795</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-24T15:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with condition  insert</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/722282#M27887</link>
      <description>Thanks yeah it was issue with Where condition I corrected and its working now thanks for your help</description>
      <pubDate>Fri, 26 Feb 2021 23:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-with-condition-insert/m-p/722282#M27887</guid>
      <dc:creator>Ashpak</dc:creator>
      <dc:date>2021-02-26T23:48:02Z</dc:date>
    </item>
  </channel>
</rss>

