Announcement

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

  • Problem with reshape wide to long

    Hi everyone,

    I have a dataset with 219 variables which I would like to reshape from wide to long. 9 of the variables are ID variables (all strings) and the variable id is unique for every observation and the other 210 variables are made out of 14 diffrent stubs (15 years each, all numeric).

    At the end you can find a short example.

    With the following code I want to reshape the data and get the following error message:

    reshape long ("umsatz"-"av"), i(ags id ui form groesse taetigkeit iddg) j(year)
    (note: j = 1 2)
    variable (1 implied name too long
    r(198);
    I already tried a lot of things but I can not find the mistake in my code.

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str21 ags str13 id str33 ui str45 form str19 groesse str42 taetigkeit str23 iddg double(umsatz1 umsatz2 gew1 gew2 bilanz1 bilanz2 ek1 ek2 anzahl1 anzahl2 av1 av2)
    "0642023" "DE60514227" "D"  "Gesellschaft" "klein"  "N" "DE*1100092949" 0      0 0 0 0       0 0       0 0  0 0       0
    "0644002" "DE60031743" "D"  "Gesellschaft" "mittel" "G" "DE*1105091680" 0      0 0 0 0       0 0       0 0  0 0       0
    "0200000" "DE21500617" "D"  "Gesellschaft" "groß"  "C" "DE21536365"    0      0 0 0 0       0 0       0 0  0 0       0
    "0321012" "DE20540838" "D"  "Gesellschaft" "groß"  "C" "DE*1101266556" 0      0 0 0 0       0 0       0 0  0 0       0
    "0646001" "DE62900646" "D"  "Gesellschaft" "groß"  "L" "DE*1104386217" 0      0 0 0 0       0 0       0 0  0 0       0
    "1604058" "DE32303213" "D"  "Gesellschaft" "groß"  "G" "DE32304708"    0      0 0 0 0       0 0       0 0  0 0       0
    "0571000" "DE41705344" "D"  "Gesellschaft" "klein"  "Q" "DE*1109023527" 0      0 0 0 0       0 0       0 0  0 0       0
    "0598024" "DE40701482" "D"  "Gesellschaft" "groß"  "G" "DE*1101513218" 0      0 0 0 0       0 0       0 0  0 0       0
    "0661000" "DE61508101" "D"  "Gesellschaft" "klein"  "E" "DE*1101707718" 0      0 0 0 0       0 0       0 0  0 0       0
    "0535000" "DE51900182" "D"  "Gesellschaft" "mittel" "M" "DE*1108936388" 0      0 0 0 0       0 0       0 0  0 0       0
    "0942143" "DE80701392" "D"  "Gesellschaft" "klein"  "N" "DE*1105609314" 0      0 0 0 0       0 0       0 0  0 0       0
    "0535000" "DE51909918" "D"  "Gesellschaft" "mittel" "M" "DE51904356"    0 342801 0 0 0 1680091 0  509337 0 52 0   11501
    "0572020" "DE41700013" "D"  "Gesellschaft" "klein"  "E" "DE*1101498409" 0      0 0 0 0       0 0       0 0  0 0       0
    "0961000" "DE80100479" "D"  "Gesellschaft" "klein"  "G" "DE*1107745553" 0      0 0 0 0       0 0       0 0  0 0       0
    "1200280" "DE20114763" "D"  "Gesellschaft" "klein"  "M" "DE20179453"    0      0 0 0 0       0 0       0 0  0 0       0
    "1200280" "DE20108690" "B+" "GmbH"                          "klein"  "S" ""                0      0 0 0 0       0 0       0 0  0 0       0
    "1200280" "DE20106753" "B+" "Gesellschaft" "klein"  "G" ""                0      0 0 0 0       0 0       0 0  0 0       0
    "1451000" "DE30300763" "D"  "Gesellschaft" "klein"  "G" "DE*1104360032" 0      0 0 0 0       0 0       0 0  0 0       0
    "0914147" "DE83302957" "D"  "Gesellschaft" "klein"  "M" "DE81757317"    0      0 0 0 0       0 0       0 0  0 0       0
    "1203532" "DE32500356" "B+" "Gesellschaft" "klein"  "A" ""                0      0 0 0 0 8364533 0 4591660 0  8 0 6660813
    "1204317" "DE32500467" "D"  "Gesellschaft" "mittel" "C" "DE*1106065410" 0      0 0 0 0       0 0       0 0  0 0       0
    "1200302" "DE33301393" "D"  "Gesellschaft " "mittel" "M" "DE33337124"    0      0 0 0 0       0 0       0 0  0 0       0
    "0200000" "DE21504447" "D"  "Gesellschaft" "klein"  "F" "DE*1104014955" 0      0 0 0 0       0 0       0 0  0 0       0
    "0341000" "DE20502389" "D"  "Gesellschaft" "groß"  "Q" "DELEI12007"    0      0 0 0 0       0 0       0 0  0 0       0
    "0333003" "DE21504426" "D"  "Gesellschaft" "klein"  "H" "DE*1106779199" 0      0 0 0 0       0 0       0 0  0 0       0
    "1502000" "DE31300799" "B+" "Gesellschaft" "klein"  "F" ""                0      0 0 0 0       0 0       0 0  0 0       0
    "0401000" "DE20501564" "D"  "Gesellschaft " "klein"  "R" "DE*1195806599" 0      0 0 0 0       0 0       0 0  0 0       0
    "0552032" "DE40500417" "D"  "Gesellschaft" "klein"  "C" "DE*1104586599" 0      0 0 0 0       0 0       0 0  0 0       0
    "1202312" "DE20103956" "D"  "Gesellschaft" "klein"  "A" "DE*1103304876" 0      0 0 0 0 3739245 0 1572082 0  6 0 2389790
    "1304010" "DE33300773" "D"  "Gesellschaft" "klein"  "L" "DE*1105821789" 0      0 0 0 0       0 0       0 0  0 0       0
    end
    ------------------ copy up to and including the previous line ------------------

    Thank you very much and kind regards

    Nick

  • #2
    does this provide the desired result,
    Code:
    reshape long umtatz gew bilanz ek anzahl av, i(ags id ui form groesse taetigkeit iddg) j(year)
    ?

    Comment


    • #3
      Thank you so much! It worked perfectly.

      Comment

      Working...
      X