Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Combine sectional data files of different years into one panel data file


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Combine sectional data files of different years into one panel data file
Date   Tue, 4 Jun 2013 18:28:04 +0100

This is a problem for -append-, not -merge-.  But you will need to
ensure that the year is a variable within each data file first.

Nick
[email protected]

On 4 June 2013 18:22, Nerissa Fanoembi <[email protected]> wrote:

> I am trying to combine cross sectional data files of different years into one panel data file. In the cross sectional files two variables uniquely identify each person. Household number and the number of the member in the household. Below I make a simple example where I have cross sections for years 2001 and 2002. Each dataset includes variables such as the identification number of the household (nohhold) and the member of the household (nomem) and some other background characteristics (for instance age and varone). I would like to have all the observations for each variable and ordered over time for each individual. I tried the merge (1:1 using nohold and nomem together to uniquely identify each individual), append, or a combination of those commands, but could not succeed.
> Could anyone please tell me the correct command I should be using.

> Example:
> 2001:
>  nohhold nomem  age varone
> 1. 6       1     64   yes
> 2. 6       2     55   yes
> 3. 21      1     54    .
> 4. 21      2     40    .
> 5. 21      3     25   no
> 2002:
>  nohhold nomem  age varone
> 1. 6       1     64   yes
> 2. 6       2     55   yes
> 3. 6       3     15   no
> 4. 21      1     54   yes
> 5. 21      2     40   yes
> Desired panel structure should be like this:
>  nohhold nomem  age varone year
> 1. 6       1     64   yes  2001
> 2. 6       1     64   yes  2002
> 3. 6       2     55   yes  2001
> 4. 6       2     55   yes  2002
> 5. 6       3     15   no   2002
> 6. 21      1     54    .   2001
> 7. 21      1     54   yes  2002
> 8. 21      2     40    .   2001
> 9. 21      2     40   yes  2002
> 10.21      3     25   no   2001

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index