<?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: integrate rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525511#M143000</link>
    <description>&lt;P&gt;Thank you,! works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Jan 2019 18:15:38 GMT</pubDate>
    <dc:creator>JHE</dc:creator>
    <dc:date>2019-01-08T18:15:38Z</dc:date>
    <item>
      <title>integrate rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525509#M142998</link>
      <description>&lt;P&gt;I have the records as :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" cellspacing="1" cellpadding="2"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;&lt;STRONG&gt;LOB&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;&lt;STRONG&gt;MEMBER_ID&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;&lt;STRONG&gt;Asthma&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;&lt;STRONG&gt;COPD&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;0100&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;200000104&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;N&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;Y&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;0100&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;200000104&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;Y&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;N&lt;/FONT&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;how could I can have result as this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" cellspacing="1" cellpadding="2"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;&lt;STRONG&gt;LOB&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;&lt;STRONG&gt;MEMBER_ID&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;&lt;STRONG&gt;Asthma&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;&lt;STRONG&gt;COPD&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;0100&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;200000104&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;Y&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;Y&lt;/FONT&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;I do not know how to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 18:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525509#M142998</guid>
      <dc:creator>JHE</dc:creator>
      <dc:date>2019-01-08T18:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: integrate rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525510#M142999</link>
      <description>&lt;P&gt;Assuming the only values are Y and N, you can use a few methods, but a nifty one is the SAS SQL MAX() function. It will take character variables and since Y &amp;gt; N alphabetically it's the max.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as 
select ID, member_ID, max(asthma) as asthma, max(copd) as copd
from have
group by id, member_id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jan 2019 18:09:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525510#M142999</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-08T18:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: integrate rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525511#M143000</link>
      <description>&lt;P&gt;Thank you,! works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 18:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525511#M143000</guid>
      <dc:creator>JHE</dc:creator>
      <dc:date>2019-01-08T18:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: integrate rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525512#M143001</link>
      <description>&lt;P&gt;My first suggestion would be to not code values as character for things that take Yes/No True/False types of values. If you code values of Yes or True as 1 and No of False as 0 then you can do a number of things.&lt;/P&gt;
&lt;P&gt;In this case a maximum value would return 1 if any of the values for group are 1 and 0 otherwise. Also you can get counts of Yes by summing the value, and percentage Yes by taking a mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example both ways, adding a numeric to use Proc Summary to get the values (and a format to show Y/N) and the kind of code that is needed to do character comparisons. I also included somewhat more complex example as a solution that works for exactly 2 records may not work for 3 or more. Also, please note the method of providing a data step to show example data. With that code people can test code against your data.&lt;/P&gt;
&lt;PRE&gt;data example;
   input lob :$4. Member_id :$9. Asthma :$1. COPD :$1.;
   Nasthma= (asthma='Y');
   Ncopd  = (copd='Y');
datalines;
0100  200000104 N Y
0100  200000104 Y N
0100  200000105 N Y
0100  200000105 Y N
0100  200000105 N N
0100  200000105 N N
0100  200000106 Y N
0100  200000106 N N
;
run;

proc sort data=example;
  by lob member_id;
run;
/* character manipulation*/
data want;
   set example;
   by lob member_id;
   length tasthma tcopd $ 1;
   Retain tasthma tcopd;
   if first.member_id then do;
      tasthma = asthma;
      tcopd = copd;
   end;
   else do;
      if tasthma='Y' then asthma=tasthma;
      else if asthma='Y' then tasthma='Y';
      if tcopd='Y' then copd=tcopd;
      else if copd='Y' then tcopd='Y';
  end;
  if last.member_id;
  drop tasthma tcopd;
run;
/* numeric and format if desired*/
proc format library=work;
value yn
0='N'
1='Y'
;
run;
proc summary data=example nway;
   class lob member_id;
   var nasthma ncopd;
   output out=want2 (drop=_:) max=;
   format nasthma ncopd yn.;
run;

&lt;/PRE&gt;
&lt;P&gt;The above implies that what you are actually asking is "if ANY record has Y for Asthma then the final result should indicate Y for Asthma, similar of COPD and grouped by the combination of lob and member_id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The sort would be required for the character comparison to get all of the like records together. The numeric approach with the CLASS variables in Proc summary does not.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 18:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525512#M143001</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-08T18:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: integrate rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525550#M143014</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
   input lob :$4. Member_id :$9. Asthma :$1. COPD :$1.;
 datalines;
0100  200000104 N Y
0100  200000104 Y N
0100  200000105 N Y
0100  200000105 Y N
0100  200000105 N N
0100  200000105 N N
0100  200000106 Y N
0100  200000106 N N
;
run;

proc sql;
create table want as 
select  LOB,MEMBER_ID,ifc(sum( Asthma='Y')&amp;gt;=1,'Y','N') as Asthma,ifc(sum( COPD='Y')&amp;gt;=1,'Y','N') as COPD
from example
group by lob,member_id;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will handle all chars,nums etc&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 19:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/integrate-rows/m-p/525550#M143014</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-08T19:40:51Z</dc:date>
    </item>
  </channel>
</rss>

