Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: reshaping database with dates ordered in wide format to long format


From   hind lazrak <hindstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: reshaping database with dates ordered in wide format to long format
Date   Sun, 10 Feb 2013 02:33:36 -0800

Hello Stata users

I have been going through the threads and tried a few hints for
questions that were somewhat similar to the problem I have, but I
haven't resolved my question yet. Hopefully, someone can lend a hand
for this one:
I have a cohort of families that are followed over time.
They are asked at one time point (3months after the birth of their
child) to list the addresses and dates of move in and move out where
they have lived since they consented to participate in the study.

For some families it is simple: they have never moved- but for others,
there is quite some movement.
The way the questionnaire was entered is shaped in wide format
For example, consider this simplified version of the data I have
For each id we have the following variables
reside3mq1 reside3mq2 reside3mq2a reside3mq2b
reside3mq3 reside3mq3a reside3mq3b
reside3mq4 reside3mq4a reside3mq4b

Data dictionary -
reside3mq1 is binary and indicates if the family has moved since consent

reside3mq`i' is the date of move-in  in address`i'
reside3mq`i'a is the postal code at address `i'  /*postal code is alphanumeric*/
reside3m`i'b is the date of move-out at address`i'

So, if `i' can go from 2 to 5 (not all family move 3 times so it varies by id)
How can I generate a data set where each id has `i' rows with move-in
and move-out dates and corresponding postal code?

Many thanks for anyone who takes the time to look at this.

Regards,

Hind
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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