<?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 - IF/THEN Conditions Process only when condition met in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328839#M73477</link>
    <description>&lt;P&gt;You should define the macro variable either by %LET - then define %MACRO DOIT().&lt;/P&gt;
&lt;P&gt;or define the macro variable as an argumnet to the macro program, the way I wrote it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %macro doit&lt;SPAN&gt;(Settle_Today_Y_N); &amp;nbsp; &lt;STRONG&gt;/* just define name to argument)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %mend doit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %doit('YES'); &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; /* asign value to argument */&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But, when you use macro variable you don't need quotes:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;either define %let Settle_Today_Y_N = YES;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;or &amp;nbsp;define &amp;nbsp; &amp;nbsp; %doit(YES);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;then check by: &amp;nbsp; %if &amp;amp;Settle_Today_Y_N = YES %then ... &amp;nbsp;&lt;STRONG&gt; /* YES without quotes */&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2017 17:59:28 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-01-31T17:59:28Z</dc:date>
    <item>
      <title>Proc SQL - IF/THEN Conditions Process only when condition met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328769#M73442</link>
      <description>&lt;P&gt;I have a &lt;STRONG&gt;daily process&lt;/STRONG&gt; with a&amp;nbsp;some user defined variables that are set, each day by the user before processing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2 Questions:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; I have a query / Proc SQL statement within the processes that I&amp;nbsp;want to run only on &lt;STRONG&gt;Settlement day&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How&amp;nbsp;could I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%Let Settle_DAY_Y_N = "YES"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If&amp;nbsp; &amp;amp;Settle_DAY_Y_N. = "YES" Then &amp;nbsp;&amp;nbsp; /*&amp;nbsp; This is the condition */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Proc SQL;&lt;/P&gt;&lt;P&gt;/*Run SQL here */&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/*&amp;nbsp; Settlement update query here */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;/* Don't Run SQL here */&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2.&amp;nbsp; (2nd Question)&amp;nbsp;Would&amp;nbsp;your solution also works for this?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%Let Settle_DAY_Y_N = "YES"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If&amp;nbsp; &amp;amp;Settle_DAY_Y_N. = "YES" Then&amp;nbsp;&amp;nbsp; /*&amp;nbsp; &lt;/STRONG&gt;This is the condition */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data work.Combine_Records;&lt;/P&gt;&lt;P&gt;set work.A work.AA work.AAA;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;Data work.Combine_Records;&lt;/P&gt;&lt;P&gt;set work.A work.AA;&amp;nbsp;&amp;nbsp; /* Since no settlement record was created drop work.AAA */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 15:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328769#M73442</guid>
      <dc:creator>Kody_devl</dc:creator>
      <dc:date>2017-01-31T15:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - IF/THEN Conditions Process only when condition met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328782#M73445</link>
      <description>&lt;P&gt;You can do it by using macro program. Pay attention to syntax:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%macro doit&lt;/STRONG&gt;(&lt;SPAN&gt;Settle_DAY_Y_N);&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %If&amp;nbsp; &amp;amp;Settle_DAY_Y_N. = YES %Then %do; &amp;nbsp; &amp;nbsp; &amp;nbsp;/*&amp;nbsp; This is the condition */&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Proc SQL;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/*Run SQL here */&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /*&amp;nbsp; Settlement update query here */&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp;%end;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%mend doit;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%doit;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can enter any sas code between&amp;nbsp;&lt;STRONG&gt;%do;&lt;/STRONG&gt; &amp;nbsp;and &amp;nbsp;&lt;STRONG&gt;%end;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 15:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328782#M73445</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-31T15:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - IF/THEN Conditions Process only when condition met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328797#M73453</link>
      <description>&lt;P&gt;And&lt;/P&gt;
&lt;P&gt;%else %do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;lt;other code&amp;gt;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro %if or %do require the code be inside a macro definition %macro/%mend construct to define and the call the macro. Otherwise use of %if or %do will generate error messages&amp;nbsp;of&amp;nbsp; attempting to use in open code.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 16:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328797#M73453</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-31T16:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - IF/THEN Conditions Process only when condition met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328798#M73454</link>
      <description>&lt;P&gt;Shmuel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perfect!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kody_Devl&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 16:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328798#M73454</guid>
      <dc:creator>Kody_devl</dc:creator>
      <dc:date>2017-01-31T16:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - IF/THEN Conditions Process only when condition met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328825#M73474</link>
      <description>&lt;P&gt;Shmuel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My version is&amp;nbsp;not evaluating correcly&amp;nbsp;as "YES" (Skips my code)&amp;nbsp;and is probably syntax.&amp;nbsp; Do you see it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Settle_Today_Y_N = 'YES'; &lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/* CAPS YES or NO */&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Settled(Settle_Today_Y_N); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%If&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;Settle_Today_Y_N.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'YES'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&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"&gt;proc import datafile = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"/sas/sasperm3_prod/yyyyyyy/xxxx/import/&amp;amp;Settled."&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;out= A_SRC_Settled dbms= xlsx replace;&lt;/P&gt;&lt;P&gt;getnames= yes;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;range= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Settled'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Settled;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;Settled&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 17:21:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328825#M73474</guid>
      <dc:creator>Kody_devl</dc:creator>
      <dc:date>2017-01-31T17:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - IF/THEN Conditions Process only when condition met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328839#M73477</link>
      <description>&lt;P&gt;You should define the macro variable either by %LET - then define %MACRO DOIT().&lt;/P&gt;
&lt;P&gt;or define the macro variable as an argumnet to the macro program, the way I wrote it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %macro doit&lt;SPAN&gt;(Settle_Today_Y_N); &amp;nbsp; &lt;STRONG&gt;/* just define name to argument)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %mend doit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %doit('YES'); &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; /* asign value to argument */&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But, when you use macro variable you don't need quotes:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;either define %let Settle_Today_Y_N = YES;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;or &amp;nbsp;define &amp;nbsp; &amp;nbsp; %doit(YES);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;then check by: &amp;nbsp; %if &amp;amp;Settle_Today_Y_N = YES %then ... &amp;nbsp;&lt;STRONG&gt; /* YES without quotes */&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 17:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-IF-THEN-Conditions-Process-only-when-condition-met/m-p/328839#M73477</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-31T17:59:28Z</dc:date>
    </item>
  </channel>
</rss>

