Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick cox <njcoxstata@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
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 NickOn 22 Mar 2011, at 15:10, "Kathleen Oberst" <Kathleen.Oberst@hc.msu.edu> wrote:
I have a dataset with person ID, discharge date, and another calculatedfield 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 3I'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 generateda marker 'y' to act as a counter for #admissions but can't really dropanyone 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 reshapebut it appears since the daysmissed and y variables can change (appropriately so) between the records, it is not working (y notconstant 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/