Statalist


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

Re: st: linking village level data to individual level data


From   Philipp Rehm <[email protected]>
To   [email protected]
Subject   Re: st: linking village level data to individual level data
Date   Sun, 27 Apr 2008 22:13:13 -0400

.
In your individual level data-set, you can generate the village id variable by typing:

gen vid=substr(pid,1,4)

Note that this assumes that the vid-information is always written into the pid-variable as the first four digits.

Then go ahead and -merge- the two data-sets on variable "vid". Something along these lines should do (there are other ways to do this):

use inividual.dta, clear // individual-level data
gen vid=substr(pid,1,4)
sort vid

preserve
use village.dta, clear // village data
sort vid
tempfile v
save `v'
restore

merge vid using `v'

HTH,
Philipp


Nirina F wrote:

Hello all,

I have individual level data and village level data.
The individual identifiers are 7character variables and start with 4
characters that represent the village where the individual is in.
           .  list pid in 1/5

     +---------+
     |    pid |
     |---------|
  1. | V001002 |
  2. | V001022 |
  3. | V001026 |
  4. | V001032 |
  5. | V001037 |
     +---------+

In the village data, there is village id variable which is similar to
the 4 characters above.
 .  list vid in 1/5

     +---------+
     |    vid  |
     |---------|
  1. | V001 |
  2. | V001 |
  3. | V001 |
  4. | V001 |
  5. | V001 |
     +---------+

My question is:  I don't know how to extract the village identifier
from the individual identifier for me to merge the village level data
into the individual level data.

I know I cannot put any attachement in the statalist emails but I hope
I am clear on my question.
Thank you in advance.
Nirina
*
*   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