Statalist


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

st: Data transformation


From   "Lina Jonsson" <lina.jonsson@vti.se>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Data transformation
Date   Mon, 12 Nov 2007 11:19:26 +0100

Dear all.

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

Any suggestions on how this can be done? 

Best Regards

Lina Jonsson

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