Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RESHAPE HELP


From   "Sarah A. Mustillo" <[email protected]>
To   [email protected]
Subject   Re: st: RESHAPE HELP
Date   Wed, 16 Oct 2002 21:14:18 -0400

What about this:

As you stated, the problem with your reshape is that your j variable needs to be unique within id. It sounds to me like you already have it though.

I am picturing that your data look this:

id edate gcount
1 6/26/94 1
2 6/27/94 1
3 6/27/94 1
3 6/28/94 2
4 6/28/94 1
4 6/28/94 2
4 6/29/94 3

If that is the case, I think you could just switch your variables around and do:

.reshape wide edate, i(id) j(gcount)

which would give you something like:

id edate1 edate2 edate3
4 6/28/94 6/28/94 6/29/94


Is that what you want? If I am wrong about the gcount variable, you could easily create a variable that numbers events by id.


Sarah



--On Wednesday, October 16, 2002 6:43 PM -0400 [email protected] wrote:


Hi.  I am a new STATA user that is working on a secondary analysis for my
dissertation research. I am trying to reconfigure a file that was set up
with  multiple record cases.  For example, a particular id# may be
contained in  this file numerous on the following variables: event #
(gcount) and edate  (month, day, year of the event). I am trying to
convert the data from long  form to wide form so that each id# is only
represented in this file once and  have run into some difficulty with the
RESHAPE command. I know based upon  what I have read in the Reference
manual and the FAQ reshape information that  I must need to create some
additional variables because the j(edate variable)  is not unique for
each id #. Let me explain that the reason the edates are  not unique is
because an individual may have experienced mutiple events, such  as a
fall, on any given date.  I wondered if anyone might be able to point me
in the right direction for how I should proceed with creating additional
variables? I have included a condensed version of my syntax and output
below.

Thanks in advance for your help,
Beth

. reshape wide gcount, i(id) j(edate)
(note: j = 11928 11946 11956 11959.............)
edate not unique within id;
there are multiple observations at the same edate within id.
Type "reshape error" for a listing of the problem observations.
r(9);

reshape error

i (id) indicates the top-level grouping such as subject id.
j (edate) indicates the subgrouping such as time.
The data are in the long form;  j should be unique within i.

There are multiple observations on the same edate within id.

The following 253 out of 3741 observations have repeated edate values:

             id       edate
  75.        45  06/26/1994
  76.        45  06/26/1994
  92.        52  06/21/1994
  93.        52  06/21/1994

(data now sorted by id edate)
*
*   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/



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