This is a classic -reshape-, but first you will need to fill in the missing values of id, date and time to make them constant, i.e.
foreach v of varlist id date time {
replace `v'=`v'[_n-1] if missing(`v')
}
reshape wide Gender Injury, i(id) j(person_id)
David
[email protected]
-----Original Message-----
From: Simon Moore [mailto:[email protected]]
Sent: 26 January 2005 15:21
To: [email protected]
Subject: st: data manipulation
I am to work with some data that has been inputted in SPSS in a rather
unusual format. Transferring from SPSS into Stata is not the problem -
rearranging the data into a format I am comfortable with is. At the
moment it looks something like this:
id date time person_id Gender Injury
1 21/1/2005 23:10 1 M Face
. . . 2 M Head
. . . 3 F Legs
2 23/1/2005 04:15 1 M Arms
. . . 2 F Feet
3 23/1/2006 05:10 1 F Face
The data refers to violent incidents in a particular area. For each
incident more than one person (the maximum is somewhere around 6 but
could go higher as new data arrives) may have been involved each
sustaining different injuries.
I would like to rearrange these data into a form something like this:
id date time gender1 injury 1 gender2 injury2 ...
As far as I can see -collapse- will not help me much. So, has anyone
had experience with this type of problem and could you point me in the
right direction?
Many thanks
Simon Moore
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/