Statalist The Stata Listserver


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

Re: st: RE: Combining two data files and follow-up data in Stata


From   "Ada Ma" <heu034@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Combining two data files and follow-up data in Stata
Date   Sat, 1 Jul 2006 23:25:24 +0100

Say your follow file is organised like this:

case     month      alive
Case1    6             Y
Case1    12           Y
Case1    18           N

case, month and alive are varaible names.  Then you write:

. reshape wide alive, i(case) j(month)

Afterwards your follow up data set will look like this:

case        alive6   alive12   alive18
case1       Y         Y          N



On 6/30/06, Ashwin Ananthakrishnan <ashwinna@yahoo.com> wrote:
Hi,

Thanks for getting back to me. I apologize if I'm
asking an obvious question but how do I reshape the
file from long to wide? Would you be able to explain
it further?

For example,

my main file has

Case1
Case2
Case3


My follow up file has

Case1      - 6 months - alive (Y)
Case1      - 12 months - alive (Y)
Case1      - 18 months - alive (N)

How do I reshape the follow up file so that it reads
              6 months          12 months     18months
Case 1           y                   y            n


Thanks,
Ashwin










--- Richard Atkins <Richard.Atkins@lshtm.ac.uk> wrote:

> You will have to reshape your followup file from
> long to wide (so each
> case is a main_ID and has variables x_1, x_2 etc
> representing the
> repeated measurements.  They use the merge command.
>
> Richard Atkins.
> London School of Hygiene and Tropical Medicine
>
> >>> JWhite@yesvirginia.org 06/30/06 12:50 pm >>>
> Try the merge command.
>
>
> Justin White
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On
> Behalf Of Ashwin
> Ananthakrishnan
> Sent: Friday, June 30, 2006 7:48 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Combining two data files and follow-up
> data in Stata
>
> Hi,
>
> I currently have 2 data files in Stata - the first
> file is the main file with a list of all the
> subjects
> in the study organised by a main_ID number. I have a
> second file which contains follow-up data - with
> each
> entry representing one follow-up visit. That file is
> sorted by the main_ID also but because each patient
> has more than 1 follow-up visit, there might be
> multiple entries per main_ID.
>
> 1. How do I combine these two data files using
> main_ID
> as the common variable?
>
> 2. How can I combine the follow-up data such that I
> have one 1 record for each main_ID number which
> lists
> the outcome at each follow-up visit?
>
> Thanks,
> Ashwin
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com
> *
> *   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/
> *
> *   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/
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
*
*   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/


--
Ada Ma
Research Fellow
Health Economics Research Unit
University of Aberdeen, UK.
http://www.abdn.ac.uk/heru/
Tel: +44 (0) 1224 553863
Fax: +44 (0) 1224 550926
*
*   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/



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