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


From   "Sarah A. Mustillo" <>
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.


--On Wednesday, October 16, 2002 6:43 PM -0400 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

Thanks in advance for your help,

. 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.

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:

*   For searches and help try:

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