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: Data Management Question


From   Kieran McCaul <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: Data Management Question
Date   Fri, 17 Jan 2014 11:20:08 +0800

...



sort state stcase vehno, stable
by state stcase vehno: gen order=_n
reshape wide mviolatn, i(state stcase vehno) j(order)




-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of SEVIGNY, ERIC
Sent: Friday, 17 January 2014 10:55 AM
To: '[email protected]'
Subject: st: Data Management Question

I have data of the following form coding state, a unique crash id (stcase), a sequential vehicle number involved in the crash (vehno), and the moving violations assessed (mviolatn). I would like to create a new variable in wide format for each non-unique combination of state, stcase, and vehno. Crash code 80007 is instructive here, where I would like to reshape the data with new variables mvioltn1...mvioltn6 coding each separate infraction. The rest of the shown cases would have mvioltn1 filled in with the indicated value and missing for the remainder. How can I accomplish this data management task?

Thanks, 

Eric Sevigny

state	stcase	vehno	mviolatn
6	62636	1	0
6	62637	1	95
6	62638	1	0
6	62638	2	0
6	62639	1	0
6	62640	1	0
6	62641	1	0
6	62642	1	95
8	80001	1	0
8	80002	1	4
8	80002	2	0
8	80003	1	0
8	80005	1	0
8	80006	1	0
8	80007	1	72
8	80007	1	92
8	80007	1	5
8	80007	1	11
8	80007	1	22
8	80007	1	1
8	80008	1	0
8	80009	1	0

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index