<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244698#M45622</link>
    <description>&lt;P&gt;The by statement:&lt;/P&gt;
&lt;PRE&gt;BY SHORT_ACCOUNT_NUMBER;&lt;/PRE&gt;
&lt;P&gt;Creates a binary value, 1 for true, 0 for false, which is set based on whether a value is the first occurrence of a value in that variable. &amp;nbsp;A bit like:&lt;/P&gt;
&lt;P&gt;SHORT_ACCOUNT_NUMBER &amp;nbsp; &amp;nbsp; &amp;nbsp;ISFIRST&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The if:&lt;/P&gt;
&lt;PRE&gt;IF FIRST.SHORT_ACCOUNT_NUMBER;&lt;/PRE&gt;
&lt;P&gt;Is the same as saying: if isfirst=1 then output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please dont code all in uppercase, it makes code painful to read.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jan 2016 14:42:08 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-01-20T14:42:08Z</dc:date>
    <item>
      <title>IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244679#M45612</link>
      <description>&lt;P&gt;What does it mean when an if statement is only followed by the name of a library?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 14:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244679#M45612</guid>
      <dc:creator>hled683</dc:creator>
      <dc:date>2016-01-20T14:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244682#M45613</link>
      <description>&lt;P&gt;You mean "name of a variable"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's the case, you are referring&amp;nbsp;to a "subsetting if". It means that any observation that does meet the criteria, is not processed further on in the data step. So any explicit or implicit&amp;nbsp;output will not be performed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you just name a variable, for a numerical&amp;nbsp;value of 0 means false (subset will occur), any other value is evaluated as true&amp;nbsp;(processing will proceed with the following steps).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have an example?&lt;/P&gt;
&lt;P&gt;Try to execute it, evaluate the results. Potentially change input data/IF statement&amp;nbsp;and see the differences.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 14:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244682#M45613</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-01-20T14:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244685#M45615</link>
      <description>&lt;P&gt;for example:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt; CR_OPEN_IO_PART_TEMP_1;&lt;/P&gt;&lt;P&gt;SET CR_OPEN_IO_PART_TEMP;&lt;/P&gt;&lt;P&gt;BY SHORT_ACCOUNT_NUMBER;&lt;/P&gt;&lt;P&gt;IF FIRST.SHORT_ACCOUNT_NUMBER;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 14:16:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244685#M45615</guid>
      <dc:creator>hled683</dc:creator>
      <dc:date>2016-01-20T14:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244692#M45619</link>
      <description>&lt;P&gt;Read this&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p0yeyftk8ftuckn1o5qzy53284gz.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p0yeyftk8ftuckn1o5qzy53284gz.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 14:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244692#M45619</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-01-20T14:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244698#M45622</link>
      <description>&lt;P&gt;The by statement:&lt;/P&gt;
&lt;PRE&gt;BY SHORT_ACCOUNT_NUMBER;&lt;/PRE&gt;
&lt;P&gt;Creates a binary value, 1 for true, 0 for false, which is set based on whether a value is the first occurrence of a value in that variable. &amp;nbsp;A bit like:&lt;/P&gt;
&lt;P&gt;SHORT_ACCOUNT_NUMBER &amp;nbsp; &amp;nbsp; &amp;nbsp;ISFIRST&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The if:&lt;/P&gt;
&lt;PRE&gt;IF FIRST.SHORT_ACCOUNT_NUMBER;&lt;/PRE&gt;
&lt;P&gt;Is the same as saying: if isfirst=1 then output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please dont code all in uppercase, it makes code painful to read.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 14:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244698#M45622</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-20T14:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244703#M45625</link>
      <description>&lt;P&gt;As a new user, it's understandable that you wouldn't understand:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF FIRST.SHORT_ACCOUNT_NUMBER;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's actually more complicated than it looks, so I can give you the overview only.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF deletes observations, and continues to process other observations.&amp;nbsp; The ones that satisfy the IF condition continue to be processed, and the others get deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FIRST.SHORT_ACCOUNT_NUMBER is created in a DATA step using a BY statement.&amp;nbsp; What it does, and how it works, will take some study on your part.&amp;nbsp; (You have already been pointed to some reference material.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The net result in this program handles cases where there are multiple observations for the same SHORT_ACCOUNT_NUMBER:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Just keep the first observation for each SHORT_ACCOUNT_NUMBER&lt;/LI&gt;
&lt;LI&gt;Delete any remaining observations for the same SHORT_ACCOUNT_NUMBER&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Hope this at least points you in the right direction.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 14:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement/m-p/244703#M45625</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-20T14:46:54Z</dc:date>
    </item>
  </channel>
</rss>

