<?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: Combining Multiple people staying at same address in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combining-Multiple-people-staying-at-same-address/m-p/447323#M112347</link>
    <description>&lt;P&gt;Should be workable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;length newname $ 50;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by account_ID address;&lt;/P&gt;
&lt;P&gt;if first.address then newname = name;&lt;/P&gt;
&lt;P&gt;else newname = trim(newname) || ' and ' || name;&lt;/P&gt;
&lt;P&gt;if last.address;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;retain newname;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;drop name;&lt;/P&gt;
&lt;P&gt;rename newname = name;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*********** EDITED to add the &lt;FONT color="#FF0000"&gt;correction&lt;/FONT&gt;.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Mar 2018 04:56:08 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-03-21T04:56:08Z</dc:date>
    <item>
      <title>Combining Multiple people staying at same address</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-Multiple-people-staying-at-same-address/m-p/447318#M112343</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to combine the names of the people staying at the same location having the same account_ID, as shown in the table below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Address&lt;/TD&gt;&lt;TD&gt;Account_ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Arnold&lt;/TD&gt;&lt;TD&gt;Pitt Street&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Stallone&lt;/TD&gt;&lt;TD&gt;Pitt Street&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Willis&lt;/TD&gt;&lt;TD&gt;Pitt Street&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Smith&lt;/TD&gt;&lt;TD&gt;George Street&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i ideally am looking to get is as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Address&lt;/TD&gt;&lt;TD&gt;Account_ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Arnold and Stallone and Willis&lt;/TD&gt;&lt;TD&gt;Pitt Street&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Smith&lt;/TD&gt;&lt;TD&gt;George Street&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Yatindra&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 04:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-Multiple-people-staying-at-same-address/m-p/447318#M112343</guid>
      <dc:creator>Yvegunta</dc:creator>
      <dc:date>2018-03-21T04:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Multiple people staying at same address</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-Multiple-people-staying-at-same-address/m-p/447323#M112347</link>
      <description>&lt;P&gt;Should be workable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;length newname $ 50;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by account_ID address;&lt;/P&gt;
&lt;P&gt;if first.address then newname = name;&lt;/P&gt;
&lt;P&gt;else newname = trim(newname) || ' and ' || name;&lt;/P&gt;
&lt;P&gt;if last.address;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;retain newname;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;drop name;&lt;/P&gt;
&lt;P&gt;rename newname = name;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*********** EDITED to add the &lt;FONT color="#FF0000"&gt;correction&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 04:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-Multiple-people-staying-at-same-address/m-p/447323#M112347</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-21T04:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Multiple people staying at same address</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-Multiple-people-staying-at-same-address/m-p/447329#M112351</link>
      <description>&lt;P&gt;Hi Yatindar,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt; infile datalines dsd ;&lt;BR /&gt; length Name $200 Address $200;&lt;BR /&gt; input Name $ Address $ Account_ID ;&lt;/P&gt;
&lt;P&gt;datalines;&lt;BR /&gt;Arnold , Pitt Street, 123&lt;BR /&gt;Stallone, Pitt Street, 123&lt;BR /&gt;Willis, Pitt Street, 123&lt;BR /&gt;Smith, George Street, 123&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;BR /&gt; by address account_id;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data required;&lt;BR /&gt; set have;&lt;BR /&gt; by address account_id;&lt;BR /&gt; length new_name $200;&lt;BR /&gt; retain new_name ' '; &lt;BR /&gt; if first.address then new_name=strip(name);&lt;BR /&gt; else new_name=strip(new_name)||' and '||strip(name);&lt;BR /&gt; name=new_name;&lt;BR /&gt; drop new_name;&lt;BR /&gt; if last.address;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please find the solution&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 04:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-Multiple-people-staying-at-same-address/m-p/447329#M112351</guid>
      <dc:creator>DR_Majeti</dc:creator>
      <dc:date>2018-03-21T04:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Multiple people staying at same address</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-Multiple-people-staying-at-same-address/m-p/447332#M112354</link>
      <description>&lt;P&gt;Use a do until() loop for this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Name :$12. Address &amp;amp;:$24. Account_ID ;
datalines;
Arnold Pitt Street  123 
Stallone Pitt Street  123 
Willis Pitt Street  123 
Smith George Street  123
; 

proc sort data=have; by account_id address name; run;

data want;
length allNames $64;
do until(last.address);
    set have; by account_id address;
    allNames = catx(" and ", allNames, name);
    end;
drop name;
rename allNames = name;
run;

proc print data=want noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Mar 2018 05:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-Multiple-people-staying-at-same-address/m-p/447332#M112354</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-21T05:21:23Z</dc:date>
    </item>
  </channel>
</rss>

