04-27-2015 04:29 AM
I read a lot of information about the merging process in SAS, but nothing helped so far. It should be an easy thing.
What I want to do:
- I have a table with information about customers
- I have a table with information about orders
--> the one thing in common they have, is a variable with information (firstname lastname). For the customers I concatenated two text variables.
/*Sort inputfile with info about customers, has the concatenated variable, one row per customer*/
proc sort data=ECom.kunden;
/*Sort inputfile with info about orders, several rows possible for one customers*/
proc sort data=ECom.bestellungen;
/*do the actual merge*/
merge ECom.kunden ECom.bestellungen;
proc print data=ECom.AlleDaten;
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).
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?
Thanks a lot for your help!
04-27-2015 11:13 AM
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 could all be the same person.
But this would be a place to start.
create table Ecom.AlleDaten as
select a.*, b.*
from ECom.bestellungen as a left join ECom.kunden as b
Better could be to use :
on a.lastname=b.lastname and a.firstname=b.firstname
As you depending on how you created the RechnungAn variable you might have concatenated names like "Bob Smith" and "Bob Smith" 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"
If you have a customer identification that would be preferable to names.