<?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: question on if then do loops in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125962#M34623</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Can someone explain whats going on in this code &lt;SPAN style="color: #222222; font-family: arial, sans-serif; background-color: #ffffff;"&gt;(especially the highlighted one)&lt;/SPAN&gt;?&lt;/SPAN&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Mar 2013 03:32:22 GMT</pubDate>
    <dc:creator>sampath</dc:creator>
    <dc:date>2013-03-04T03:32:22Z</dc:date>
    <item>
      <title>question on if then do loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125961#M34622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can someone explain whats going on in this code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 22:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125961#M34622</guid>
      <dc:creator>sampath</dc:creator>
      <dc:date>2013-03-02T22:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: question on if then do loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125962#M34623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Can someone explain whats going on in this code &lt;SPAN style="color: #222222; font-family: arial, sans-serif; background-color: #ffffff;"&gt;(especially the highlighted one)&lt;/SPAN&gt;?&lt;/SPAN&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 03:32:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125962#M34623</guid>
      <dc:creator>sampath</dc:creator>
      <dc:date>2013-03-04T03:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: question on if then do loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125963#M34624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks to me like it is trying to look for ICU admissions and changes some flag variables based on whether they are found or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you be more specific about what you want help with.&amp;nbsp; Do you not understand the SAS statements or the logic of the programmer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 04:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125963#M34624</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-04T04:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: question on if then do loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125964#M34625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;This is basically the calculation for the "Return to ICU" by the same patient during a single vist(which is identified by the bill number)&lt;/P&gt;&lt;P&gt;It would be great if you can help us understand the logic:&lt;/P&gt;&lt;P&gt;ALSO there is a series of statments like this towards the end.....I had difficulty understanding these toooo!!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if (olicuf and not(input(put(dept2,$icud.),f1.0))) then do;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Regards&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 12:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125964#M34625</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-04T12:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: question on if then do loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125965#M34626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Work your way out from the lowest level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PUT(DEPT,$ICUD.)&amp;nbsp; will convert the value of DEPT using the format $ICUD.&amp;nbsp; If you look at the definition of that format it will basically convert DEPT to '1' when it is 'ICU' and everything else to '0'.&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;INPUT(...,F1.0) will convert a one character text string to a number. So the '1' becomes a 1 and the '0' becomes a 0.&amp;nbsp; (NOTE you could have saved one function call if you had defined an INFORMAT that would convert the character strings in DEPT into numbers 0 1.&amp;nbsp; Then you could have just coded INPUT(DEPT,ICUD.).&amp;nbsp; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOT (...) .&amp;nbsp; NOT is a logical operator.&amp;nbsp; So if the value in the () is true it becomes false, if it is false it becomes true.&amp;nbsp; SAS treats 0 as false and anything else as true. So the zeros become ones and the ones become zeros.&amp;nbsp; So basically this is saying DEPT is NOT the ICU .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OLICUF AND ... -&amp;nbsp; This is telling SAS to treat variable OLICUF as a boolean value. 0 is false and anything else is true.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if OLICUF is true and DEPT is NOT the ICU then ....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 12:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125965#M34626</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-04T12:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: question on if then do loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125966#M34627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Could you explain this with a simple dataset.I have a big dataset and could not use the putlog statement to see whats happening i the background&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 13:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125966#M34627</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-05T13:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: question on if then do loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125967#M34628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To try out the complex syntax just write a simple data step and try different values.&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do dept2 = 'ICU', 'ER' ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; codestring = put(dept2,$icud.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; codenum = input(codestring,f1.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; notcode = not codenum ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put (dept2 codestring codenum notcode) (=) ;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To debug the whole program run it for just a few BILL_NUM values .&lt;/P&gt;&lt;P&gt;You could add a WHERE statement to subset (don't overwrite your production dataset!).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or you could only put to the log for particular cases.&lt;/P&gt;&lt;P&gt;Something like this (you might want to add other variables).&lt;/P&gt;&lt;P&gt;if bill_num = '12345' then putlog (bill_num dept2 &lt;SPAN style="color: #222222; font-family: arial, sans-serif; background-color: #ffffff;"&gt;olunt olicuf icuctr olicu&lt;/SPAN&gt;) (=) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could place it in the various DO/END loops.&amp;nbsp; You might want to adjust the text put to the log so that you can tell which loop is executing.&lt;/P&gt;&lt;P&gt;For example you might use this one after the first DO; statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if bill_num = '12345' then putlog 'FIRST.BILL_NUM Loop '&amp;nbsp; (bill_num dept2 &lt;SPAN style="color: #222222; font-family: arial, sans-serif; background-color: #ffffff;"&gt;olunt olicuf icuctr olicu&lt;/SPAN&gt;) (=) ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 14:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125967#M34628</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-05T14:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: question on if then do loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125968#M34629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;Thanks for the reply. I need some more clarification on your explanation of the line of code a couple of days ago...on the NOT Operator&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if (olicuf and not(input(put(dept2,$icud.),f1.0))) then do;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; ICUtoutf=1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; olicuf=0; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; olicu='';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly if it is the first of the bill number and ICU olicuf is given a value 1 and it is retained&lt;/P&gt;&lt;P&gt;the &lt;STRONG&gt;highlighted code&lt;/STRONG&gt; is for the dept2 when it is not first of the bill number&lt;/P&gt;&lt;P&gt;Could you now explain me how the NOT logical operator works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;billno&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dept2&amp;nbsp;&amp;nbsp; olicuf&lt;/P&gt;&lt;P&gt;111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ICU&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understood it till:&lt;/P&gt;&lt;P&gt;after the format is applied since its not ICU it becomes&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; not (0)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;could you explain what happens from there.....&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;i dint quite get ur explanation on the NOT Logical Operator&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 16:06:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-on-if-then-do-loops/m-p/125968#M34629</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-05T16:06:00Z</dc:date>
    </item>
  </channel>
</rss>

