<?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: If then statements not in data step? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758099#M239342</link>
    <description>The ^= syntax isnt working for me for some reason, and when I try to use %symexist(var1) it is returning true seemingly no matter what I do (if i comment out or delete the %let definition it still runs the code using that variable somehow. I haven have a delete all work statement at the top and it continues to do that) Any ideas?</description>
    <pubDate>Thu, 29 Jul 2021 14:19:11 GMT</pubDate>
    <dc:creator>mancel3</dc:creator>
    <dc:date>2021-07-29T14:19:11Z</dc:date>
    <item>
      <title>If then statements not in data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758069#M239338</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am writing a program with a series of lines at the top to manually enter various macros. Based on what macros are entered, I want to be able to run different lines of code and am not sure if this is possible in sas. high level overiew of what I want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let var1 = 123;&lt;/P&gt;&lt;P&gt;%let var2 = 'string';&lt;/P&gt;&lt;P&gt;/* %let var3 = 567; */&lt;/P&gt;&lt;P&gt;/* %let var5 = 999;&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if var3 is not null then&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; **proc sql code here**&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else if var5 is not null then&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; **different proc sql code here**&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else if var1 is not null then&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; **different proc sql code again**&lt;/P&gt;&lt;P&gt;&amp;nbsp;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible in any way in sas? The user would be able to comment out the variables not in use, and it would run different querys depending on which variables were in use. Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 13:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758069#M239338</guid>
      <dc:creator>mancel3</dc:creator>
      <dc:date>2021-07-29T13:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: If then statements not in data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758071#M239339</link>
      <description>&lt;P&gt;You can do this with macro statements. If you have SAS 9.4 TS1M5 or later&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;var3^=  %then %do;
          **proc sql code here**
%end;
%else %if &amp;amp;var5^=  %then %do;
          **different proc sql code here** 
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;If you are using earlier versions of SAS, you would have to include the above code in a macro.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 13:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758071#M239339</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-29T13:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: If then statements not in data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758099#M239342</link>
      <description>The ^= syntax isnt working for me for some reason, and when I try to use %symexist(var1) it is returning true seemingly no matter what I do (if i comment out or delete the %let definition it still runs the code using that variable somehow. I haven have a delete all work statement at the top and it continues to do that) Any ideas?</description>
      <pubDate>Thu, 29 Jul 2021 14:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758099#M239342</guid>
      <dc:creator>mancel3</dc:creator>
      <dc:date>2021-07-29T14:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: If then statements not in data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758103#M239345</link>
      <description>&lt;P&gt;"isn't working for me"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives us no information on how to move forward or help you. (Also, my code did not require %symexist, so I know you are not using my code)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Show us your code. Show us the LOG (all of the log, not just the ERROR messages)&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 15:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758103#M239345</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-29T15:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: If then statements not in data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758130#M239354</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/389635"&gt;@mancel3&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The ^= syntax isnt working for me for some reason, and when I try to use %symexist(var1) it is returning true seemingly no matter what I do (if i comment out or delete the %let definition it still runs the code using that variable somehow. I haven have a delete all work statement at the top and it continues to do that) Any ideas?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;%symexist will return "true" if the macro variable was created anytime during the SAS session ifthe variable was made as global macro variable such as the %let statements you show.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show the entire syntax and notes from the log. There wasn't any indications that %symexist was relevant to the problem you discuss.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 15:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758130#M239354</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-29T15:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: If then statements not in data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758292#M239409</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;%symexist will return "true" if the macro variable was created anytime during the SAS&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;and hasn't been %SYMDEL eted. Just to clarify for the OP.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 22:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758292#M239409</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-29T22:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: If then statements not in data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758308#M239416</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; If you are using earlier versions of SAS, you would have to include the above code in a macro.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;If you use an older version of SAS, here's another way that works in open code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;  %sysfunc(ifc( &amp;amp;var3^=, %str( **proc sql code here**           )
, %sysfunc(ifc( &amp;amp;var5^=, %str( **different proc sql code here** )
, )) ))         
&lt;/LI-CODE&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;</description>
      <pubDate>Fri, 30 Jul 2021 07:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-then-statements-not-in-data-step/m-p/758308#M239416</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-30T07:49:32Z</dc:date>
    </item>
  </channel>
</rss>

