Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: merge files of tables with headers and multiple identifiers in each table


From   Minsoo Kim <ibsulkim@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: merge files of tables with headers and multiple identifiers in each table
Date   Wed, 13 Jul 2011 00:41:34 -0500

Hi,

I am using STATA SE/11.2 and I have been trying to merge two excel
files. Each excel file has about 600 hundreds of tables
with headers for each table and with two empty rows between each
table.
I would like to illustrate what I need to do. The two original excel
files and the Goal Data Set I need to generate can be
simiplified as follows:

<Excel File1>
Name  FileYr   Table             V1  V2  V3  V4
AB       2000      IS     1997    1   15    3    12
AB       2000      IS     1998    4    3    14    2
AB       2000      IS     1999    7   12   16    4

Name  FileYr   Table   Asset   V5  V6  V7  V8
AB       2000      BS     1997    6    14    6    2
AB       2000      BS     1998    12    7    9    1

Name  FileYr   Table  Liabilities  V9    V10    V11  V12
AB       2000      BS     1997       1      18      17     4
AB       2000      BS     1998       10      7      42     5


<Excel File2>
Name  FileYr   Table             V1  V2  V3   V13
AB       2001      IS     1998    4    3    14
AB       2001      IS     1999    7   12   16
AB       2001      IS     2000   17  11     9    10

Name  FileYr   Table   Asset   V5  V6  V7  V8  V14
AB       2001      BS     1998    12    7    9    1
AB       2001      BS     1999    5    21    5   11   22

Name  FileYr   Table  Liabilities  V9    V10    V12
AB       2001      BS     1998       10      7       5
AB       2001      BS     1999       71      60     40


<Goal Data Set>
Name  FileYr   Table             V1  V2  V3  V4  V13
AB       2000      IS     1997    1   15    3    12
AB       2000      IS     1998    4    3    14    2
AB       2000      IS     1999    7   12   16    4
AB       2001      IS     2000   17  11    9           10

Name  FileYr   Table   Asset   V5  V6  V7  V8  V14
AB       2000      BS     1997    6    14    6    2
AB       2000      BS     1998    12    7    9    1
AB       2001      BS     1999    5    21    5   11   22

Name  FileYr   Table  Liabilities  V9    V10    V11  V12
AB       2000      BS     1997       1      18      17     4
AB       2000      BS     1998       10      7      42     5
AB       2001      BS     1999       71      60            40

As above, I need to add data in the seconde excel files(using) into the first
data set(master). When using doesn't have any match with
master, I still need to add using into the master data set in a seperate table.
As there are multiple identifiers and headers in each table, merge
command by itself cannot generate the Goal Data Set as I desire.
Can anyone help me to make it happen in right way?

Thanks,


-- 
Minsoo
The University of Chicago
E-mail: minsoo1@uchicago.edu
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index