Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Data transformation


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Data transformation
Date   Mon, 12 Nov 2007 10:26:25 -0000

Try 

. reshape wide weight cost, i(Accidentnr vehiclenr) 

Lina Jonsson

I have a dataset concerning accidents involving two vehicles that I have
in two formats, wide and long like this:

long:

Accidentnr	vehiclenr	weight 	cost
1		0		1000		35000
1		1		1500		150000
2		0		1200		150000
2		1		1700		750000

wide:

Accidentnr	weight0	weight1	cost0		cost1
1		1000		1500		35000		150000
2		1200		1700		150000	750000

Now I whould like to transform the data to a long format but with
information also concering the other vehicle involved in each accident
like this:

Accidentnr	vehiclenr	ownweight 	othersweight	owncost
otherscost
1		0		1000		1500
35000		150000
1		1		1500		1000
150000	35000	
2		0		1200		1700
150000	750000
2		1		1700		1200
750000	150000

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



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index