Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: how to reshape data so that can perform calculations


From   Nick cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: how to reshape data so that can perform calculations
Date   Tue, 22 Mar 2011 16:28:32 +0000

bysort id: keep if _N > 1

Nick

On 22 Mar 2011, at 15:10, "Kathleen Oberst" <[email protected]> wrote:

I have a dataset with person ID, discharge date, and another calculated
field in a long format as follows:

Id    discharge date    daysmissed    y
x    1/1/2010        14        1
x    2/1/2010        9        2
y    1/5/2010        0        1
z    2/8/10        25        1
z    4/10/10        19        2
z    9/30/10        8        3


I'm trying to keep just those records of people who had >1 discharge and then I want to calculate the elapsed time between dicharges. I generated
a marker 'y' to act as a counter for #admissions but can't really drop
anyone where y equals 1 because I will need that first d/c date for the subsequent calculation. I've not had luck with reshape. I tried reshape
but it appears since the daysmissed and y variables can change
(appropriately so) between the records, it is not working (y not
constant error message). I'd welcome any suggestions. Than* For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index