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

From |
James Hicks <james@earlyvoting.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Manipulating a data structure |

Date |
Thu, 19 Jun 2008 16:36:54 -0700 |

Tobias,

Thanks for the tip: I did. It turns out to have been a problem with unique identifiers and subgroupings, although Stata was spewing out some strange output.

James

On Jun 19, 2008, at 1:42 PM, Tobias Pfutze wrote:

Did you specify the "string" option when using reshape? ************************************************* Tobias Pfutze Visiting Assistant Professor Georgetown Public Policy Institute ----- Original Message ----- From: James Hicks <james.hicks@reed.edu> Date: Thursday, June 19, 2008 3:19 pm Subject: st: Manipulating a data structureHi all:

I have a simple question (sorry!) about reformatting a data structure.

A simplified version of my current data looks like this:

cou prec race mode votetype total

1 1 1 1 over x1

1 1 1 1 under y1

1 1 1 1 blank z1

1 1 1 2 over x2

1 1 1 2 under y2

1 1 1 2 blank z2

1 1 1 3 over x3

1 1 1 3 under y3

1 1 1 3 blank z3

1 1 2 1 over x4

1 1 2 1 under y4

1 1 2 1 blank z4

1 1 2 2 over x5

1 1 2 2 under y5

1 1 2 2 blank z5

1 1 2 3 over x6

1 1 2 3 under y6

1 1 2 3 blank z6

1 2 1 1 over x7

1 2 1 1 under y7

1 2 1 1 blank z7

1 2 1 2 over x8

1 2 1 2 under y8

1 2 1 2 blank z8

1 2 1 3 over x9

1 2 1 3 under y9

1 2 1 3 blank z9

etc...

This pattern repeats first for a number of different values of

'race',

and then all over again for several values of 'prec'. 'Cou' is

uniform

within each of the datasets. Since the smallest unit that we want

to

analyze is cou x prec x race x mode, I'm trying to make the data

take

on this more compact shape:

cou prec race mode over under blank

1 1 1 1 x1 y1 z1

1 1 1 2 x2 y2 z2

1 1 1 3 x3 y3 z3

1 1 2 1 x4 y4 z4

1 1 2 2 x5 y5 z5

1 1 2 3 x6 y6 z6

1 1 3 1 x7 y7 z7

1 1 3 2 x8 y8 z8

1 1 3 3 x9 y9 z9

1 2 1 1 x10 y10 z10

1 2 1 2 x11 y11 z11

1 2 1 3 x12 y12 z12

1 2 2 1 x13 y13 z13

1 2 2 2 x14 y14 z14

1 2 2 3 x15 y15 z15

1 2 3 1 x16 y16 z16

1 2 3 2 x17 y17 z17

1 2 3 3 x18 y18 z18

So, I want to turn the 'votetype' variable into three separate

variables for each of its values. I thought this was a case for

reshape, but I can't seem to produce the right result. Can anyone

point me in the right direction?

Many thanks,

James

*

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

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

**References**:**Re: st: Manipulating a data structure***From:*Tobias Pfutze <tp95@georgetown.edu>

- Prev by Date:
**st: xttobit not converging log likelihood "not concave"** - Next by Date:
**st: let loop stop when the first variable x becomes 0** - Previous by thread:
**Re: st: Manipulating a data structure** - Next by thread:
**Re: st: Manipulating a data structure** - Index(es):

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