<?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: Problems in appending two tables in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Re-Problems-in-appending-two-tables/m-p/1172#M329</link>
    <description>Thank you Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
I just did that like this:&lt;BR /&gt;
&lt;BR /&gt;
Data NewFile;&lt;BR /&gt;
merge file1 file2 file3 file4;&lt;BR /&gt;
by ID;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
This is like putting whatever variable in all the file into the newfile. So the newfile contain all the variables in all the files (4 times the number in total ).&lt;BR /&gt;
Also, to do this, the ID has to be sorted in asceding or descending order beforehand.&lt;BR /&gt;
&lt;BR /&gt;
**************************&lt;BR /&gt;
&lt;BR /&gt;
However, I still haven't figured out whether it still work if file1 and file2 has more than 1 similar variable ( Maybe ID and Place )&lt;BR /&gt;
&lt;BR /&gt;
*****************************</description>
    <pubDate>Thu, 03 Aug 2006 10:21:18 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2006-08-03T10:21:18Z</dc:date>
    <item>
      <title>Re: Problems in appending two tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Re-Problems-in-appending-two-tables/m-p/1170#M327</link>
      <description>What I want to do is to combined table A and table B to become Table C according to the column of 'name'as below:&lt;BR /&gt;
&lt;BR /&gt;
Table A&lt;BR /&gt;
Name    Age  Birthdate  &lt;BR /&gt;
David    12   12 august&lt;BR /&gt;
Michael  13   14 august&lt;BR /&gt;
&lt;BR /&gt;
Table B&lt;BR /&gt;
Name    Age  Place   Married&lt;BR /&gt;
David    12   Town    Yes&lt;BR /&gt;
Aileen   14   Uptown  No&lt;BR /&gt;
&lt;BR /&gt;
Table C&lt;BR /&gt;
Name&lt;BR /&gt;
Name   Age   Birthdate   Place   Married&lt;BR /&gt;
David  12    12 august    NA      NA&lt;BR /&gt;
Michael 13   14 august    Town      NA&lt;BR /&gt;
Aileen   14  NA           Uptown  No&lt;BR /&gt;
&lt;BR /&gt;
1. How do i come across in doing that? &lt;BR /&gt;
2. What do i do to the column that has same attribute in table A and table B? Should I match them as well ? What if 2 tables have same column name but different observation, would there be an error ?&lt;BR /&gt;
&lt;BR /&gt;
Thank you</description>
      <pubDate>Tue, 01 Aug 2006 12:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Re-Problems-in-appending-two-tables/m-p/1170#M327</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-08-01T12:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problems in appending two tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Re-Problems-in-appending-two-tables/m-p/1171#M328</link>
      <description>Hi,&lt;BR /&gt;
  What you want to do is not generally considered to be appending the two tables. Consider this example, where both files have the same variables&lt;BR /&gt;
[pre]&lt;BR /&gt;
FILE1              FILE2&lt;BR /&gt;
-----              -----&lt;BR /&gt;
grp num           grp num&lt;BR /&gt;
 AA 111            XX 999&lt;BR /&gt;
 BB 222            YY 888&lt;BR /&gt;
 CC 333            ZZ 777&lt;BR /&gt;
[/pre]&lt;BR /&gt;
  &lt;BR /&gt;
  If I appended those two tables together, one on "top" of the other, I would get a file that looked like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Second file appended to first file:&lt;BR /&gt;
grp num&lt;BR /&gt;
 AA 111           &lt;BR /&gt;
 BB 222           &lt;BR /&gt;
 CC 333  &lt;BR /&gt;
 XX 999  &lt;BR /&gt;
 YY 888        &lt;BR /&gt;
 ZZ 777&lt;BR /&gt;
[/pre]&lt;BR /&gt;
  On the other hand, if my 2 data files looked like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
OrderFile           PaidFile&lt;BR /&gt;
----------          --------&lt;BR /&gt;
name type owed    name   type  paid&lt;BR /&gt;
Alf  web   100     Alf   web   100&lt;BR /&gt;
Alf  phone 300     Alf   phone 300&lt;BR /&gt;
Bill web   400     Bill  web   400&lt;BR /&gt;
Bob  phone 222     Dora  web   200&lt;BR /&gt;
Dora web   333     &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
  And I wanted to join the two table together or combine them "horizontally", I might want my resulting table to look like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Newfile&lt;BR /&gt;
-------------------             &lt;BR /&gt;
name type owed paid    &lt;BR /&gt;
Alf  web   100  100&lt;BR /&gt;
Alf  phone 300  300&lt;BR /&gt;
Bill web   400  400&lt;BR /&gt;
Bob  phone 222    .&lt;BR /&gt;
Dora web   333  200  &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
  In EG, you would need to build a query that performed a JOIN on the two tables. EG has a graphical query builder that lets you join 2 or more tables together. For more information, consult the EG Help files. In the table of contents for EG topics, look for the "Building Queries" topic and for the "Joining Tables" topic. Also under the "Selecting Data" topic, you will find information about selecting columns for your query.&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 02 Aug 2006 20:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Re-Problems-in-appending-two-tables/m-p/1171#M328</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2006-08-02T20:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problems in appending two tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Re-Problems-in-appending-two-tables/m-p/1172#M329</link>
      <description>Thank you Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
I just did that like this:&lt;BR /&gt;
&lt;BR /&gt;
Data NewFile;&lt;BR /&gt;
merge file1 file2 file3 file4;&lt;BR /&gt;
by ID;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
This is like putting whatever variable in all the file into the newfile. So the newfile contain all the variables in all the files (4 times the number in total ).&lt;BR /&gt;
Also, to do this, the ID has to be sorted in asceding or descending order beforehand.&lt;BR /&gt;
&lt;BR /&gt;
**************************&lt;BR /&gt;
&lt;BR /&gt;
However, I still haven't figured out whether it still work if file1 and file2 has more than 1 similar variable ( Maybe ID and Place )&lt;BR /&gt;
&lt;BR /&gt;
*****************************</description>
      <pubDate>Thu, 03 Aug 2006 10:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Re-Problems-in-appending-two-tables/m-p/1172#M329</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-08-03T10:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problems in appending two tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Re-Problems-in-appending-two-tables/m-p/1173#M330</link>
      <description>Hi!&lt;BR /&gt;
  I see that you used the Merge statement. There are a lot of different issues to consider when you are using a merge. For example, a merge by ID and Place would be entirely possible and depending on your data, might give you different results than just a merge by ID. The data step merge works best, in my opinion, if you are doing one-to-one or one-to-many merges.&lt;BR /&gt;
&lt;BR /&gt;
  You can control which variables come from which dataset by using the (DROP=) or (KEEP=) data set option in your Merge statement. You can further control your processing by using the (IN=) option for each data set -- because it will give you a variable name to test in an IF statement.&lt;BR /&gt;
&lt;BR /&gt;
  Describing everything you need to know about how MERGE works could take a LONG time. I suggest you look up MERGE in the documentation and/or consult some of these user group papers (listed below) or contact Tech Support for help. One technique that works really well for me is to create several small data files, which would allow my code to test all the possible combinations of the data, then once the test data is combined correctly, I know how my MERGE is going to work and I point my program at the production data.&lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
** some papers **&lt;BR /&gt;
&lt;A href="http://support.sas.com/techsup/technote/ts644.html" target="_blank"&gt;http://support.sas.com/techsup/technote/ts644.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi28/096-28.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi28/096-28.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.ats.ucla.edu/STAT/sas/library/nesug99/ad155.pdf" target="_blank"&gt;http://www.ats.ucla.edu/STAT/sas/library/nesug99/ad155.pdf&lt;/A&gt;</description>
      <pubDate>Thu, 03 Aug 2006 13:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Re-Problems-in-appending-two-tables/m-p/1173#M330</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2006-08-03T13:35:28Z</dc:date>
    </item>
  </channel>
</rss>

