<?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 help in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217431#M53501</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for being unclear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the if statement to work as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if the patients dscode is in &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;('01','03','04','05','06','07','08','15','20','21','43','50','51','63','64','65','70') OR the ONLY dscode the patient has = 30 then disch =1 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other logic I would like to add is: if last dscode by pt id and admit date = 30 then disch = 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reeza is correct, there are multiple rows per patient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expected output is to have disch = 1 if the dscode falls in the above list OR if the patient &lt;SPAN style="text-decoration: underline;"&gt;only&lt;/SPAN&gt; has a ds code of 30 (no other ds codes) OR if the last DSCode by admit date for that patient =30&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thank you for the responses.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Aug 2015 18:12:47 GMT</pubDate>
    <dc:creator>Jse</dc:creator>
    <dc:date>2015-08-05T18:12:47Z</dc:date>
    <item>
      <title>If statement help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217428#M53498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; IF DSCODE IN('01','03','04','05','06','07','08','15','20','21','43','50','51','63','64','65','70')THEN&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DISCH=1; ELSE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DISCH=0; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to add criteria to this if statement.&amp;nbsp; I would like the criteria to include something like:&amp;nbsp; OR if the only dscode by pt id = 30 THEN... (meaning if a patient only has a dscode of 30 in the data, then flag)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is this possible? can someone help me on the syntax?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;If there is another way to approach this, I would appreciate any suggestions.&amp;nbsp; Another option I was thinking about was If last&amp;nbsp; dscode=30 then flag &lt;SPAN style="font-size: 13.3333330154419px;"&gt;(by admit date and patient)&lt;/SPAN&gt;.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jesse&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 17:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217428#M53498</guid>
      <dc:creator>Jse</dc:creator>
      <dc:date>2015-08-05T17:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: If statement help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217429#M53499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you need to post sample data, since I'm assuming that you're dealing with a scenario where an ID can have multiple records.&lt;/P&gt;&lt;P&gt;Please include expected output as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 17:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217429#M53499</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-08-05T17:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: If statement help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217430#M53500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if dscode = '30' then flag = 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you are asking sounds simple, I'm not sure if I understand what you are wanting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 18:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217430#M53500</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-08-05T18:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: If statement help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217431#M53501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for being unclear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the if statement to work as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if the patients dscode is in &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;('01','03','04','05','06','07','08','15','20','21','43','50','51','63','64','65','70') OR the ONLY dscode the patient has = 30 then disch =1 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other logic I would like to add is: if last dscode by pt id and admit date = 30 then disch = 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reeza is correct, there are multiple rows per patient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expected output is to have disch = 1 if the dscode falls in the above list OR if the patient &lt;SPAN style="text-decoration: underline;"&gt;only&lt;/SPAN&gt; has a ds code of 30 (no other ds codes) OR if the last DSCode by admit date for that patient =30&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thank you for the responses.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 18:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217431#M53501</guid>
      <dc:creator>Jse</dc:creator>
      <dc:date>2015-08-05T18:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: If statement help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217432#M53502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would start with:&lt;/P&gt;&lt;P&gt;DISCH =( DSCODE IN('01','03','04','05','06','07','08','15','20','21','43','50','51','63','64','65','70') );&lt;/P&gt;&lt;P&gt;To assign the basic 0/1 flag.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; OR if the only dscode by pt id = 30 THEN...&lt;/P&gt;&lt;P&gt;This looks like you want an except that would be applied because of a single value occurring among multiple records Is that the case? If so you need to determine if that is true for ANY of the records for the value of your Pt_ID variable. Which you are not going to do with a single pass in a data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To identify "last" you will need to decide last within an ordered group. If the Patient has multiple records with the same admin date this might work. If the data isn't sorted in the order you need then sort it first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sort data=have; by AdminDate PatientId;run;&amp;nbsp; /* This would likely be more useful if there was another variable to specify the order within the patient's record*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by AdminDate PatientId;&amp;nbsp; /* if your data isn't actually sorted but is in a processing sequence then add NOTSORTED */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DISCH =( DSCODE IN('01','03','04','05','06','07','08','15','20','21','43','50','51','63','64','65','70') );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last.PatientId then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if dscode = '30' then &amp;lt;whatever your flag was&amp;gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 18:13:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217432#M53502</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-08-05T18:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: If statement help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217433#M53503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thank you so much for your help.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;OR if the only dscode by pt id = 30 THEN...&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;This looks like you want an except that would be applied because of a single value occurring among multiple records Is that the case? If so you need to determine if that is true for ANY of the records for the value of your Pt_ID variable. Which you are not going to do with a single pass in a data step.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I will work with the LAST statement you gave me.&amp;nbsp; It should flag ds code 30 if that is a patients only or last ds code.&amp;nbsp; Thank you again.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 18:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-help/m-p/217433#M53503</guid>
      <dc:creator>Jse</dc:creator>
      <dc:date>2015-08-05T18:43:40Z</dc:date>
    </item>
  </channel>
</rss>

