Try this:
. gen vid=substr(pid, 1, 4)
Zhiqiang Wang, PhD
School of Medicine, University of Queensland
Email: [email protected]
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nirina F
Sent: Monday, 28 April 2008 12:01 PM
To: [email protected]
Subject: st: linking village level data to individual level data
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/