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]

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


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: how to reshape data so that can perform calculations
Date   Tue, 22 Mar 2011 17:22:40 +0000

Solutions for the -drop-ping arrived independently from several sources. 

What remains up in the air is the idea that this problem requires a -reshape-. What you want just requires a thinning down (in fact, not even that, as you could just ignore the singletons). The basic data structure remains the same. 

Nick 
[email protected] 

Kathleen Oberst

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

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