Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

merging data --- was Re: st: To: [email protected]


From   Ronnie Babigumira <[email protected]>
To   [email protected]
Subject   merging data --- was Re: st: To: [email protected]
Date   Sat, 06 May 2006 19:52:25 +0200

Not sure I understand however here is my take. You will need to have a common identification variable for the firms in the two datasets. This firmid can be a string (firm name) or a number. Names are tricky as small difference such as ATT and AT&T which may be the same firm will be considered as two firms when you try to merge. This is why it is good to have the ids as numbers which you can then hold as strings (precision issues). Bottom line is you need to be able to identify each firm in your data so that Stata can know which data belongs to which firm.

Having done that you should have
1. The crosssection dataset (with a firmid)
2. The employeesurvey (with a firmid)

use crosssection, clear
sort firmid
save tempa, replace //if you dont want to change the original sort order

use employeesurvey, clear
sort firmid
merge firmid using tempa
tab _merge //see -help merge- for what this result means, a perfect merge should be 3.

HTH
peter harper wrote:

Dear Statalist

This is a small question. I want to include to the crosssection dataset I am using now, which is a management questionnaire which has crosssection data on all firms with 10 or more employees with an employee survey of the same dataset, but in the employee survey they have only included 25 employee at random from each workplace.
Can I confirm, is the command (note, firmid and nameofsecondfile are not the precise command)

. merge firmid using nameofsecondfile

But how do I obtain the firmid please.

Thanks
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index