Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: data manipulation


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: data manipulation
Date   Wed, 25 Jun 2003 20:08:13 +0100

Branislav Seslija

I need to flip the data so that each unique combination of 
prog_id and object_i is a unique variable with the counties 
in each state becoming row entries. Unfortunatly these data 
are for a single year so that i can not fool reshape into doing 
what i wanted to do. Any tips would be very beneficial.

prog_id object_i f_state f_county amounttotal amount year
10.001 GG 11 001 65000 65000 1983
10.001 GG 12 001 27382 27382 1983
10.001 GG 25 025 2377300 2377300 1983
10.001 GG 32 031 179800 179800 1983
10.001 GG 48 201 2608800 2608800 1983
10.025 GG 01 081 171250 171250 1983
10.025 GG 01 101 -26371 -26371 1983
10.025 GG 04 013 49800 24900 1983
10.025 GG 04 019 15000 15000 1983
10.025 GG 05 119 27000 27000 1983
10.025 GG 06 025 100000 100000 1983


>>> The absence of variation in -year- doesn't prohibit a -reshape-.
You just need to construct a column identifier yourself. 
Try 

bysort prog_id object_i : gen id = _n 
reshape wide f_state-year , i(prog_id object_i) j(id)

Having said that, this new data structure is likely 
to be more awkward than the old, at least in my 
experience. 

Nick
n.j.cox@durham.ac.uk 
*
*   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