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: grouping variable
From
Lars Folkestad <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: grouping variable
Date
Thu, 12 Jan 2012 12:19:41 +0100
Dear List
After searching the web i will have to ask you - co-listers.
I have a dataset of patients and admissions.
Id sex hospital ward date_admission date_discharge
Data is in long format and i would like it to be reshaped to wide format.
Some participants have up to 150 different admissions.
My problem is that i dont have a unique grouping variable available (some
patients have been admitted to the same wards twice or more on the same
day)
I would like to do the following
Sort by id
Genereate a grouping variable 1-_n for each id
Reshape the lot to wide using i(id) j(groupvar)
But i cannot se how to to this.
Any other ways do reshape?
lars
*
* 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/