Your second email clarifies some things, but
I can't yet understand your data structure.
On problem 1) in your first email, below:
If all blocks were like that for -id- of 101 1002,
then a solution would be
bysort id (summig) : replace summig[_N] if mi(summig)
but you have only got to look at -id- of 101 1003
to see two basic problems:
1. More than one person identified in -idmig-.
2. More than one line not empty in -summig-.
How do you expect to handle those kinds of
observations?
Nick
[email protected]
[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?
>
*
* 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/