<?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 else in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508338#M136518</link>
    <description>&lt;P&gt;Part one is a no-brainer, so I leave that to you.&lt;/P&gt;
&lt;P&gt;For part two, what should happen if you have multiple rows for a claim with identical identifiers or where one of the rows has a value other than 1 or 4?&lt;/P&gt;</description>
    <pubDate>Mon, 29 Oct 2018 13:47:57 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-10-29T13:47:57Z</dc:date>
    <item>
      <title>If else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508336#M136517</link>
      <description>&lt;P&gt;In the below dataset, I want to convert the identifier like &amp;nbsp;0s to 1s, 1s to 4s,missing as missing. After the conversion if the claim is having the identifier as 1's and 4's then I've to convert it to 0's. e.g. If the claim has two rows, one with identifier 1 and the other with identifier 4, then I've to convert it to one row and it should have identifier 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Input dataset:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="165"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="101"&gt;claim&lt;/TD&gt;
&lt;TD width="64"&gt;Identifier&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;123&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;456&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;789&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;999&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;999&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;output dataset:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl66" style="height: 15.0pt; width: 48pt;"&gt;claim&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;Identifier&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;123&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;456&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;789&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;999&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 29 Oct 2018 13:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508336#M136517</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-29T13:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: If else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508338#M136518</link>
      <description>&lt;P&gt;Part one is a no-brainer, so I leave that to you.&lt;/P&gt;
&lt;P&gt;For part two, what should happen if you have multiple rows for a claim with identical identifiers or where one of the rows has a value other than 1 or 4?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 13:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508338#M136518</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-29T13:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: If else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508339#M136519</link>
      <description>&lt;P&gt;What happens if you have more than 2 rows with the values 1 or 4?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 13:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508339#M136519</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-29T13:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: If else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508342#M136520</link>
      <description>&lt;P&gt;I need to keep all the claims after the conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example for the desired output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl66" style="height: 15.0pt; width: 48pt;"&gt;claim&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;Identifier&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;123&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;456&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;789&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;999&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;999&lt;/TD&gt;
&lt;TD align="right" class="xl67" style="border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;789&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;456&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 29 Oct 2018 14:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508342#M136520</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-29T14:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: If else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508344#M136521</link>
      <description>&lt;P&gt;We no need to do anything if we've multiple rows of claims. I just want to know how to convert 1's and 4's for the same claim to 0's.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typically want to know how to convert two rows to one row (identifier with '0') for the same claim with different identifier (1's and 4's).&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 14:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508344#M136521</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-29T14:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: If else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508346#M136522</link>
      <description>&lt;P&gt;Please post the expected output for this dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input claim identifier;
cards;
123 .
222 1
222 1
222 4
333 4
333 4
333 4
444 .
444 1
444 4
444 4
456 1
555 .
555 1
555 4
789 0
999 4
999 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Oct 2018 14:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508346#M136522</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-29T14:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: If else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508404#M136546</link>
      <description>Desired output is, &lt;BR /&gt;Claim    Identifier&lt;BR /&gt;222        0&lt;BR /&gt;333        4&lt;BR /&gt;444        0&lt;BR /&gt;456        1&lt;BR /&gt;555        1&lt;BR /&gt;789        0&lt;BR /&gt;999        0</description>
      <pubDate>Mon, 29 Oct 2018 16:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508404#M136546</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-29T16:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: If else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508616#M136619</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Desired output is, &lt;BR /&gt;Claim Identifier&lt;BR /&gt;222 0&lt;BR /&gt;333 4&lt;BR /&gt;444 0&lt;BR /&gt;456 1&lt;BR /&gt;555 1&lt;BR /&gt;789 0&lt;BR /&gt;999 0&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input claim identifier;
cards;
123 .
222 1
222 1
222 4
333 4
333 4
333 4
444 .
444 1
444 4
444 4
456 1
555 .
555 1
555 4
789 0
999 4
999 1
;
run;

data want;
set have;
by claim;
retain flag_1 flag_4 flag_0 flag_other;
if first.claim
then do;
  flag_1 = 0;
  flag_4 = 0;
  flag_0 = 0;
  flag_other = 0;
end;
select (identifier);
  when (1) flag_1 + 1;
  when (4) flag_4 + 1;
  when (0) flag_0 = 1;
  otherwise flag_other = 1;
end;
if last.claim
then do;
  if flag_4 and not flag_1 then identifier = 4;
  else if flag_1
  then do;
    if flag_4 and not flag_other or flag_4 &amp;gt; 1
    then identifier = 0;
    else identifier = 1;
  end;
  else identifier = 0;
  if flag_1 + flag_4 + flag_0 then output;
end;
drop flag_:;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;claim    identifier

 222          0   
 333          4   
 444          0   
 456          1   
 555          1   
 789          0   
 999          0   
&lt;/PRE&gt;
&lt;P&gt;Voila!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 09:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else/m-p/508616#M136619</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-30T09:46:49Z</dc:date>
    </item>
  </channel>
</rss>

