Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • reshape wide

    I have this dataset:
    Code:
    mun    ano    d_fem    fxetaria    pop
    110001    1991    no    0 to 4 years    2328
    110001    1991    no    5 to 9 years    2139
    110001    1991    no    10 to 14 years    2202
    110001    1991    no    15 to 19 years    1984
    110001    1991    no    20 to 24 years    1677
    110001    1991    no    25 to 29 years    1532
    110001    1991    no    30 to 34 years    1216
    110001    1991    no    35 to 39 years    932
    110001    1991    no    40 to 44 years    742
    110001    1991    no    45 to 49 years    641
    110001    1991    no    50 to 54 years    539
    110001    1991    no    55 to 59 years    446
    110001    1991    no    60 to 64 years    309
    110001    1991    no    65 to 69 years    172
    110001    1991    no    70 to 74 years    72
    110001    1991    no    75 to 79 years    48
    110001    1991    no    80 years+    30
    110001    1991    yes    0 to 4 years    2199
    110001    1991    yes    5 to 9 years    2141
    110001    1991    yes    10 to 14 years    2033
    110001    1991    yes    15 to 19 years    1907
    110001    1991    yes    20 to 24 years    1456
    110001    1991    yes    25 to 29 years    1271
    110001    1991    yes    30 to 34 years    998
    110001    1991    yes    35 to 39 years    774
    110001    1991    yes    40 to 44 years    605
    110001    1991    yes    45 to 49 years    521
    110001    1991    yes    50 to 54 years    386
    I would like to have only 1 row for each municipality(var mun)-year(var ano), but stata do not allow me to do the command below:

    Code:
    . reshape wide pop, i (mun ano) j (d_fem fxetaria)
    variable d_fem is numeric
    r(109);

  • #2
    I try to -tostring- the variables but stata doesnt allow me neither - how can I drop label values?

    Code:
    . tostring fxetaria d_fem, replace
    fxetaria has value label; no replace
    d_fem has value label; no replace

    Comment


    • #3
      I believe that the error message in post #1 is because the syntax for reshape wide (see help reshape) only allows one variable, and optionally a list of values, for the j() option, so the error message is because Stata thinks that "fxetaria" is a string that you are specifying as a value for the numeric variable d_fem.

      On a similar question at Stack Overflow I suggest a way of doing two successive reshape wides to accomplish something similar.

      With that said, the experienced users sere generally agree that, with few exceptions, Stata makes it much more straightforward to accomplish complex analyses using a long organization rather than wide organization of the same data. So my reaction would be to not reshape this dataset wide; it will likely make your subsequent analyses more difficult.
      Last edited by William Lisowski; 26 Aug 2015, 19:07.

      Comment

      Working...
      X