bysort id1 (id) : gen byte which = _n
Nick
[email protected]
[email protected]
> I have a dataset with contains the results of a multiple
> imputation, so
> each observation is contained 5 times. I'm trying to divide
> this dataset
> into 5 different ones (one for each imputed dataset) but I cannot find
> an easy way to do it.
> My identification variables are 'id' and 'id1':
>
> list id id1
>
> +--------------+
> | id id1 |
> |--------------|
> 1. | 11 1 |
> 2. | 12 1 |
> 3. | 13 1 |
> 4. | 14 1 |
> 5. | 15 1 |
> |--------------|
> 6. | 21 2 |
> 7. | 22 2 |
> 8. | 23 2 |
> 9. | 24 2 |
> 10. | 25 2 |
> |--------------|
> 11. | 31 3 |
> 12. | 32 3 |
> 13. | 33 3 |
> 14. | 34 3 |
> 15. | 35 3 |
> |--------------|.
> =2E
>
> The only thing i could think about is (if 3000 observations):
>
> forvalues m=3D1/3000 {
> forvalues n=3D2/5 {
> drop if id =3D=3D `m'`n'
> }
> }
>
> So i'll be keeping imputed dataset number 1. then repeat this for the
> rest of datasets. As you can see this is slow and not really
> practical.
*
* 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/