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]

st: Merge problem


From   Erik Aadland <erikaadland@hotmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: Merge problem
Date   Fri, 4 Oct 2013 08:18:30 +0000

Dear Statalist.

I have two datasets. One dataset (A) contains the variables "year" and "firm_id". A firm observation ("firm_id") occurs only once in a given "year". 

The other dataset (B) contains the variables "year", "period_id" and "firm_id". There are many periods within a given year, and firm observations ("firm_id") are nested within periods. So a given firm ("firm_id") may occur several times in a given year. The firms in (A) are not the same firms as in (B). The structure of (A) and (B) are as follows.

(A):
year	firm_id
2003	1
2003	2
2003	3
2003	4
2004	1
2004	2
2004	5
2004	6

(B):
year	period_id	firm_id
2003	1			11
2003	1			12
2003	2			13
2003	2			14
2003	2			11
2004	3			11
2004	3			12
2004	3			15
2004	4			16
2004	4			17

I want to merge the firms in (A) into (B) such that the firms in (A) in a given year occur in all periods for the corresponding year in (B). The problem is that I don't have "period_id" for my firm observations in (A).

Is there a smart way to handle this problem? I use Stata 12.

Any input on this would be much appreciated.

Sincerely,
Erik 		 	   		  
*
*   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