Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Multiple labels?


From   [email protected]
To   [email protected]
Subject   st: RE: Multiple labels?
Date   Wed, 26 Nov 2003 01:00:49 +0100 (MEZ)

Dear Nick,
Thanks for your reply. I'll try to make things clear here. Variable -id- is 
the household identifier indicating for instance village 101 and household 
1002. Actually I have grouped the last two information so that here 
-101 1002- is a label while the underlying numerical value is 1.
-idmig- is household's members registration order and allows me to identify 
the member who migrated and in the first household 3 then means the third 
member.
Then I generated -summmig-  as indicated in the do-file below using 
information in variable -mmig- (type of inkind item remitted: shoes, etc.) 
and qmmig (quantity of that item).
hf indicates migrant that are not member of the household.
For my first question (former email), I want -summmig- to be in the same row 
as migrant with -idmig==3-, because it is currently wrongly affected to the 
first person in the household.
Hope this is now clear and would really appreciate any suggestion.
Adama
*------------------DO-FILE--------------------------
version 8.2

use migrant, clear
preserve
ds mmig*
local nature "`r(varlist)'"

ds hfmmig*
local hfnature "`r(varlist)'"

ds qmmig*  
local qnature "`r(varlist)'"

ds qhfmmig*
local qhfnature "`r(varlist)'"


keep vfolio mfolio `nature' `hfnature' `qnature' `qhfnature' 

capture destring, replace
sort vfolio mfolio
save inkind, replace

sort vfolio mfolio  /*village and household identifier*/

renvars `nature' `hfnature' `qnature' `qhfnature', postdrop(3)  

reshape long mmig@a mmig@b mmig@c mmig@d mmig@e mmig@f hfmmig@a hfmmig@b 
hfmmig@c hfmmig@d hfmmig@e hfmmig@f qmmig@a qmmig@b qmmig@c qmmig@d qmmig@e 
qmmig@f qhfmmig@a qhfmmig@b qhfmmig@c qhfmmig@d qhfmmig@e qhfmmig@f, i
(vfolio mfolio) j(inkindmove)

*browse if vfolio==101&mfolio==1002|vfolio==102&mfolio==1004

capture lab var inkindmove "person who migrates"

lab def nature 0 "nothing" 1 "shoes" 2 "rice" 3 "" 4 "" 5 "" 6 "" 7 "" 8 "" 
9 ""
foreach case in mmiga mmigb mmigc mmigd mmige mmigf hfmmiga hfmmigb hfmmigc 
hfmmigd hfmmige {
lab val `case' nature
}
foreach quant in qmmiga qmmigb qmmigc qmmigd qmmige qhfmmiga qhfmmigb 
qhfmmigc qhfmmigd qhfmmige {
tostring `quant', replace
}
*********
*by vfolio mfolio `var'move:
egen summmiga = concat(mmiga qmmiga), p(" ") 
egen summmigb = concat(mmigb qmmigb), p(" ") 

egen summmigc = concat(mmigc qmmigc), p(" ") 
egen summmigd = concat(mmigd qmmigd), p(" ") 

egen summmige = concat(mmige qmmige), p(" ") 
egen summmigf = concat(mmigf qmmigf), p(" ") 

 
egen summmig = concat(summmiga summmigb summmigc summmigd summmige), p(" ") 
****
egen sumhfmmiga = concat(hfmmiga qhfmmiga), p(" ") 
egen sumhfmmigb = concat(hfmmigb qhfmmigb), p(" ") 

egen sumhfmmigc = concat(hfmmigc qhfmmigc), p(" ") 
egen sumhfmmigd = concat(hfmmigd qhfmmigd), p(" ") 

egen sumhfmmige = concat(hfmmige qhfmmige), p(" ") 
*egen sumhfmmigf = concat(hfmmigf qhfmmigf), p(" ")
egen sumhfmmig= concat(sumhfmmiga sumhfmmigb sumhfmmigc sumhfmmigd 
sumhfmmige), p(" ")

browse if vfolio==101&mfolio==1002|vfolio==102&mfolio==1004
 
dropmiss  mmigf 
browse
replace sumhfmmig = trim(sumhfmmig)
replace summmig = trim(summmig)
browse
replace summmig = subinstr(summmig, ".", " ",.)
replace sumhfmmig = subinstr(sumhfmmig, ".", " ",.)

browse if vfolio==101&mfolio==1002|vfolio==102&mfolio==1004


save inkind, replace
*
*   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