<?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 statement does not return the correct one in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-statement-does-not-return-the-correct-one/m-p/640227#M190635</link>
    <description>&lt;P&gt;Thanks, your code works. what happened to my original code? I am curious.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 21:08:43 GMT</pubDate>
    <dc:creator>fsuzhang</dc:creator>
    <dc:date>2020-04-15T21:08:43Z</dc:date>
    <item>
      <title>if statement does not return the correct one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-does-not-return-the-correct-one/m-p/640215#M190628</link>
      <description>&lt;P&gt;the following simple script is supposed to output loannum, but it output state, I can not find where the logic is wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let loan_level_data_flag=1;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; _NULL_ ;&lt;/P&gt;&lt;P&gt;if &amp;amp;loan_level_data_flag. = &lt;STRONG&gt;1&lt;/STRONG&gt; then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let by_option=loannum;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;else if &amp;amp;loan_level_data_flag. ^= &lt;STRONG&gt;1&lt;/STRONG&gt; then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let by_option=state;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put &amp;amp;by_option.;&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;</description>
      <pubDate>Wed, 15 Apr 2020 20:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-does-not-return-the-correct-one/m-p/640215#M190628</guid>
      <dc:creator>fsuzhang</dc:creator>
      <dc:date>2020-04-15T20:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: if statement does not return the correct one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-does-not-return-the-correct-one/m-p/640223#M190633</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let loan_level_data_flag=1;

data _NULL_ ;

if &amp;amp;loan_level_data_flag. = 1 then

   do;

    call symputx( 'by_option','loannum');

   end;

else if &amp;amp;loan_level_data_flag. ^= 1 then

   do;

   
    call symputx( 'by_option','state');

end;

run;

%put &amp;amp;by_option.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Apr 2020 21:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-does-not-return-the-correct-one/m-p/640223#M190633</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-04-15T21:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: if statement does not return the correct one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-does-not-return-the-correct-one/m-p/640227#M190635</link>
      <description>&lt;P&gt;Thanks, your code works. what happened to my original code? I am curious.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 21:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-does-not-return-the-correct-one/m-p/640227#M190635</guid>
      <dc:creator>fsuzhang</dc:creator>
      <dc:date>2020-04-15T21:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: if statement does not return the correct one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-does-not-return-the-correct-one/m-p/640228#M190636</link>
      <description>&lt;P&gt;I'm afraid macro language %let is a compile time operation and so it executes before datastep execution begins, therefore What you need is an execution time operation, or in other words an interface to the macro facility to function at execution and create a macro variable during data step execution and the store the variable in a symbol table. CALL SYMPUTX does that.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 21:16:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-does-not-return-the-correct-one/m-p/640228#M190636</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-04-15T21:16:25Z</dc:date>
    </item>
  </channel>
</rss>

