[email protected]
> I got a dataset with information about each migrant's
> inkind remittances to
> his family in the home country (variables mmig recording
> the item code and
> qmmig the quantity remitted of that item).
> Using -egen, concat- to create summmig the dataset is now
> as follows:
>
> +---------------------------------------------------+
> | id idmig summmig dummyinkind |
> |---------------------------------------------------|
> 1. | 101 1002 . 1 5 7 5 3 7 0 0 . |
> 2. | 101 1002 . . |
> 3. | 101 1002 3 1 |
> 4. | 101 1002 . . |
> 5. | 101 1002 . . |
> |---------------------------------------------------|
> 6. | 101 1002 . . |
> 7. | 101 1002 . . |
> 8. | 102 1003 . 0 0 0 0 0 0 0 0 . |
> 9. | 102 1003 . 0 0 0 0 0 0 0 0 0 0 . |
> 10. | 102 1003 3 0 |
> |---------------------------------------------------|
> 11. | 102 1003 . . |
> 12. | 102 1003 5 0 |
> 13. | 102 1003 . . |
> 14. | 102 1003 . . |
> 15. | 102 1004 . 4 0 0 0 0 0 0 . |
> |---------------------------------------------------|
> 16. | 102 1004 . 0 0 0 0 0 0 . |
> 17. | 102 1004 3 1 |
> 18. | 102 1004 . . |
> 19. | 102 1004 5 0 |
> 20. | 102 1004 . . |
> |---------------------------------------------------|
> 21. | 102 1004 . . |
> 22. | 102 1004 . . |
> 23. | 102 1005 1 5 7 0 0 0 0 0 0 1 |
> 24. | 102 1005 . . |
> 25. | 102 1005 . . |
> |---------------------------------------------------|
> 26. | 102 1005 . . |
> 27. | 102 1005 . . |
> 28. | 102 1005 . . |
> 29. | 102 1005 . . |
> 30. | 102 1005 . . |
> +---------------------------------------------------+
> The first row of summmig (item code followed by quantity)
> tells me that 5
> shoes, 5 bags of maize and 7 dresses have been
> sent by member number 3 (idmig) during his migration. Now I
> am facing the
> following difficulties:
> 1) how to affect to the member 3 himself the record that
> appears in row 1,
> summmig being a string.
> 2) is it possible to use multiple labels for these outputs
> (after -destring-
> ing summmig) in a way that allows me
> to read directly from screen "5 shoes, 5 bags of maize and
> 7 dresses "
> rather than the codes "1 5 7 5 3 7"?
> 3) How can I create the last column (dummyinkind) so that
> each member who
> migrant gets 1 if variable -summmig- contains
> any figure that is different from 0?
1) Don't understand this. Please rephrase
or give an example.
2) It would be easier to answer this given
the upstream information on how -summig-
was produced. That is, I would rather start
from your original variables than from the
concatenated variable.
3)
gen dummyinkind = 0
forval i = 1/9 {
replace dummykind = 1 if index(summig, "`i'")
}
Nick
[email protected]
*
* 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/