Saturday, March 18, 2006

Re: st: reshaping problem: unique values in other variables

Thank you Svend!

At 12:00 AM 3/17/2006, you wrote: >Michael wrote: > >I have data with the following structure: >list id rec med afev wheeze cough date agev >+---------------------------------------------------+ >| id dset rec med afev wheeze cough | >|---------------------------------------------------| >| 2 b 1 0 -9 0 0 | >| 2 b 2 1 -9 0 0 | >| 2 a 1 1 1.70 0 0 | >| 2 a 2 0 1.80 0 0 | >| 6 b 1 1 -9 0 1 | >| 6 b 2 1 -9 0 0 | >| 6 a 1 0 2.08 0 1 | >| 6 a 2 0 1.85 0 0 | >+---------------------------------------------------+ > >I wish to reorganize the data so that there is one row for each ID, >with subsets for dset (a or b) and rec (1 or 2) for each of the variables: >med, afev, wheeze, cough. > >My goal is to have: >id med(a1) med(b1) med(a2) med(b2) afev(a1) afev(b1) afev(a2) afev(b2) >2 1 0 0 1 1.70 -9 1.80 -9 >6 0 1 0 1 2.08 -9 1.85 -9 > >I have tried using the reshape command but each subset does not have unique >values of the variables afev, wheeze, and cough. ... >--------------------------------------------------------------- > >A way to do it us to create one -rec- variable from -dset- and -rec-, >and next drop -dset-: > > replace rec=rec+10 if dset=="a" > replace rec=rec+20 if dset=="b" > drop dset > reshape wide med-cough , i(id) j(rec) > >Hope this helps >Svend > >________________________________________________________ > >Svend Juul >Institut for Folkesundhed, Afdeling for Epidemiologi >(Institute of Public Health, Department of Epidemiology) >Vennelyst Boulevard 6 >DK-8000 Aarhus C, Denmark >Phone, work: +45 8942 6090 >Phone, home: +45 8693 7796 >Fax: +45 8613 1580 >E-mail: sj@soci.au.dk >_________________________________________________________ > >* >* 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/

Best wishes, Michael

____________________________________

Michael McCulloch Pine Street Clinic 124 Pine Street, San Anselmo, CA 94960-2674 tel 415.407.1357 fax 415.485.1065 email: mm@pinest.org web: www.pinest.org www.pinestreetfoundation.org

* * 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/


Tag:


Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?