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

From |
ra248@columbia.edu |

To |
statalist@hsphsun2.harvard.edu |

Subject |
RE: st: Re: How to extract and recode variables in a multiple member household survey |

Date |
Fri, 11 Feb 2005 10:44:04 -0500 |

Thank you very much Nick and Friedrich. I will try the -reshape- as you both suggested. Regina Quoting Nick Cox <n.j.cox@durham.ac.uk>: > In addition, your example shows that you > want to zap the originals once they have > been copies, so that you > would need two extra lines in your > loop: > > replace S_`M' = . in `i' > replace A_`M' = . in `i' > > If I were doing this, I would -reshape-, as Friedrich > suggested. That would be easier if you used names S_0 > and A_0 rather than SA and MA. That way it would be > easy to sort mothers to the start of each block of > observations. > > Nick > n.j.cox@durham.ac.uk > > n j cox > > > Friedrich's advice is very good. Nevertheless here is one way > to > > do what you want: > > > > gen SA = . > > gen MA = . > > qui forval i = 1/`=_N' { > > local M = Mom[`i'] > > replace SA = S_`M' in `i' > > replace MA = A_`M' in `i' > > } > > > > >>> ra248@columbia.edu > > > > The variables S_i, A_i represent characteristics of household > member > > i. The column Mom gives me the underscored value of where the > Mom's > > characteristics are. For instance, in the first household, the > mom's > > characteristics are S_2 and A_2 cause Mom takes the value 2. In > the > > second household, Mom is in S_1 and A_1... > > > > Id Mom S_1 A_1 S_2 A_2 S_3 A_3 ... S_46 A_46 > > 1 2 0 24 0 22 1 12 ... 0 67 > > 2 1 1 29 0 32 0 8 ... . . > > . > > . > > 20 3 1 76 0 75 0 46 ... 1 41 > > . > > . > > > > What I want to create is the following: > > > > Id Mom S_1 A_1 S_2 A_2 S_3 A_3 ... S_46 A_46 SA MA > > 1 2 0 24 . . 1 12 ... 0 67 0 22 > > 2 1 . . 0 32 0 8 ... . . 1 29 > > . > > . > > 20 3 1 76 0 75 . . ... 1 41 0 46 > > > > * > * 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/

**References**:**RE: st: Re: How to extract and recode variables in a multiple member household survey***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: solving equation AX=0** - Next by Date:
**st: calling variables** - Previous by thread:
**RE: st: Re: How to extract and recode variables in a multiple member household survey** - Next by thread:
**st: solving equation AX=0** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |