<?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 IF THEN Debugging in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/IF-THEN-Debugging/m-p/87840#M25079</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Need some help with this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA Rawcompustat8;&lt;/P&gt;&lt;P&gt;SET work.Rawcompustat6;&lt;/P&gt;&lt;P&gt;IF PSTKRV&amp;gt;0 THEN BM=(SEQ-PSTKRV+TXDITC);&lt;/P&gt;&lt;P&gt;IF PSTKRV&amp;lt;0 and PSTKL&amp;gt;0 THEN BM=(SEQ-PSTKL+TXDITC);&lt;/P&gt;&lt;P&gt;IF PSTKRV&amp;lt;0 and PSTKL&amp;lt;0 and PSTK&amp;gt;0 THEN BM=(SEQ-PSTK+TXDITC);&lt;/P&gt;&lt;P&gt;IF PSTKRV&amp;lt;0 and PSTKL&amp;lt;0 and PSTK&amp;lt;0 THEN BM=(SEQ+TXDITC);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code works fine for the first 3 sentences of "IF". However, the last "IF" gave outputs of periods (.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't figure out where I went wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks guys!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Oct 2012 04:38:26 GMT</pubDate>
    <dc:creator>Benn</dc:creator>
    <dc:date>2012-10-06T04:38:26Z</dc:date>
    <item>
      <title>IF THEN Debugging</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-THEN-Debugging/m-p/87840#M25079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Need some help with this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA Rawcompustat8;&lt;/P&gt;&lt;P&gt;SET work.Rawcompustat6;&lt;/P&gt;&lt;P&gt;IF PSTKRV&amp;gt;0 THEN BM=(SEQ-PSTKRV+TXDITC);&lt;/P&gt;&lt;P&gt;IF PSTKRV&amp;lt;0 and PSTKL&amp;gt;0 THEN BM=(SEQ-PSTKL+TXDITC);&lt;/P&gt;&lt;P&gt;IF PSTKRV&amp;lt;0 and PSTKL&amp;lt;0 and PSTK&amp;gt;0 THEN BM=(SEQ-PSTK+TXDITC);&lt;/P&gt;&lt;P&gt;IF PSTKRV&amp;lt;0 and PSTKL&amp;lt;0 and PSTK&amp;lt;0 THEN BM=(SEQ+TXDITC);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code works fine for the first 3 sentences of "IF". However, the last "IF" gave outputs of periods (.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't figure out where I went wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks guys!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Oct 2012 04:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-THEN-Debugging/m-p/87840#M25079</guid>
      <dc:creator>Benn</dc:creator>
      <dc:date>2012-10-06T04:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN Debugging</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-THEN-Debugging/m-p/87841#M25080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've re-coded your IF sequence a bit. It still does exactly the same - I just find it easier to debug.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data rawcompustat8 missed_cases;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set work.rawcompustat6;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if pstkrv&amp;gt;0 then bm=(seq-pstkrv+txditc);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else if pstkrv&amp;lt;0 then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pstkl&amp;gt;0 then bm=(seq-pstkl+txditc);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if pstkl&amp;lt;0 then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pstk&amp;gt;0 then bm=(seq-pstk+txditc);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if pstk&amp;lt;0 then bm=(seq+txditc);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else output missed_cases;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output rawcompustat8;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can see 2 reasons for ending up with missings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. You don't cover cases where your "selection" variables are exactly zero - so there "BM" will be missing&lt;/P&gt;&lt;P&gt;2. For the case where "IF PSTKRV&amp;lt;0 and PSTKL&amp;lt;0 and PSTK&amp;lt;0" is true one or both of the 2 variables you're summing is missing - so the result stored in BM would be missing (which is represented as a '.'). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've added a table for missed cases. In there will be all rows you've missed which should allow you to determine why your code is not working as expected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Oct 2012 06:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-THEN-Debugging/m-p/87841#M25080</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-10-06T06:50:05Z</dc:date>
    </item>
  </channel>
</rss>

