<?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 One to many merge by name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/One-to-many-merge-by-name/m-p/204217#M267038</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I read a lot of information about the merging process in SAS, but nothing helped so far. It should be an easy thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- I have a table with information about customers&lt;/P&gt;&lt;P&gt;- I have a table with information about orders&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&amp;gt; the one thing in common they have, is a variable with information (firstname lastname). For the customers I concatenated two text variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;/*Sort inputfile with info about customers, has the concatenated variable, one row per customer*/&lt;/P&gt;&lt;P&gt;proc sort data=ECom.kunden;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by RechnungAn;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*Sort inputfile with info about orders, several rows possible for one customers*/&lt;/P&gt;&lt;P&gt;proc sort data=ECom.bestellungen;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by RechnungAn;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*do the actual merge*/&lt;/P&gt;&lt;P&gt;data ECom.AlleDaten;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge ECom.kunden ECom.bestellungen;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by RechnungAn;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*show all*/&lt;/P&gt;&lt;P&gt;proc print data=ECom.AlleDaten;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is one table, but no real merging all information is separately. I would like to have the infos customer - orders, meaning for each order I would like to have more information that is stored at the customer (e.g. address).&lt;/P&gt;&lt;P&gt;I could imagine that there is some issue if the variables RechnungAn don't have the same length maybe? Or that the concatenating process messes something up?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Apr 2015 08:29:17 GMT</pubDate>
    <dc:creator>Peppermint</dc:creator>
    <dc:date>2015-04-27T08:29:17Z</dc:date>
    <item>
      <title>One to many merge by name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/One-to-many-merge-by-name/m-p/204217#M267038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I read a lot of information about the merging process in SAS, but nothing helped so far. It should be an easy thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- I have a table with information about customers&lt;/P&gt;&lt;P&gt;- I have a table with information about orders&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&amp;gt; the one thing in common they have, is a variable with information (firstname lastname). For the customers I concatenated two text variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;/*Sort inputfile with info about customers, has the concatenated variable, one row per customer*/&lt;/P&gt;&lt;P&gt;proc sort data=ECom.kunden;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by RechnungAn;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*Sort inputfile with info about orders, several rows possible for one customers*/&lt;/P&gt;&lt;P&gt;proc sort data=ECom.bestellungen;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by RechnungAn;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*do the actual merge*/&lt;/P&gt;&lt;P&gt;data ECom.AlleDaten;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge ECom.kunden ECom.bestellungen;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by RechnungAn;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*show all*/&lt;/P&gt;&lt;P&gt;proc print data=ECom.AlleDaten;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is one table, but no real merging all information is separately. I would like to have the infos customer - orders, meaning for each order I would like to have more information that is stored at the customer (e.g. address).&lt;/P&gt;&lt;P&gt;I could imagine that there is some issue if the variables RechnungAn don't have the same length maybe? Or that the concatenating process messes something up?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 08:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/One-to-many-merge-by-name/m-p/204217#M267038</guid>
      <dc:creator>Peppermint</dc:creator>
      <dc:date>2015-04-27T08:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: One to many merge by name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/One-to-many-merge-by-name/m-p/204218#M267039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1) relying on Name is poor practice because you may get different people with the same name in you customer base, the more customers the more likely. 2) The same person might appear in your database with two names Robert Smith, Rob Smith, or Bob Smith&amp;nbsp; could all be the same person.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this would be a place to start.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table Ecom.AlleDaten as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select a.*, b.*&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from ECom.bestellungen as a left join ECom.kunden as b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a.RechnungAn=b.RechnungAn;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Better could be to use :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a.lastname=b.lastname and a.firstname=b.firstname&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you depending on how you created the RechnungAn variable you might have concatenated names like "Bob Smith" and "Bob&amp;nbsp; Smith"&amp;nbsp; with one and 2 spaces between names and those wouldn't match. Also different lengths might cause a problem comparing "Bob Smith" to "Bob Smit"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have a customer identification that would be preferable to names.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/One-to-many-merge-by-name/m-p/204218#M267039</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-04-27T15:13:37Z</dc:date>
    </item>
  </channel>
</rss>

