Announcement

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

  • Stata fails to recognise the unbalancedness of a panel after -destring-

    Dear all,

    I use a unbalanced panel with observations of 11 countries over 31 years (in the example below I reduced the dataset). Most observations are missing at the margins but there are also some gaps in between the timespawn.
    After loading the data into Stata, all variables are notified as strings.

    I use -encode- to chnage the string variable "country" into a numerical one
    Code:
    encode country, generate(country1)
    drop country
    For all the other variables, which are in fact numerical and just not recognized as such by Stata, I want to use -destring-.
    Code:
    destring, replace
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long country1 int year double(ca private_credit RBEE dom_credit_private)
    1 1990   .699 84.89272                 .                 .
    1 1991   .035 87.09544                 .                 .
    1 1992  -.385 88.68573                 .                 .
    1 1993  -.532 90.17465                 .                 .
    1 1994 -1.467 89.09375 107.7608333333333                 .
    1 1995  -2.86 89.61104          110.5725                 .
    1 1996 -2.838 92.32991 107.2491666666667                 .
    1 1997 -2.546 95.90814 103.0266666666667                 .
    1 1998 -1.852        . 103.3908333333333                 .
    1 1999 -2.261        .          101.9425                 .
    1 2000  -.706 98.34511 98.82083333333334                 .
    1 2001  -.796 88.74946 99.10666666666667 89.71336187972271
    1 2002  2.102  87.6879 99.56083333333333 88.52152557320208
    1 2003  1.548 86.85045 102.4033333333333 87.80636589467738
    1 2004  2.076 85.58643          103.4175 87.76584572961241
    1 2005  2.258 88.84132 102.6216666666667 94.32410575726391
    1 2006  3.295 91.80573 101.7891666666667 94.43760642465615
    1 2007  3.802 90.49928 102.2041666666667 92.91988389099338
    1 2008   4.49 93.00035 102.2258333333333 95.81296635768743
    1 2009  2.596 97.28807          102.6725 97.73957466639996
    1 2010  2.855 96.51866               100 98.52832394446925
    2 1990  1.808   34.257                 .                 .
    2 1991  2.307 35.10204                 .                 .
    2 1992  2.898 54.78268                 .                 .
    2 1993  5.117 73.80525                 .                 .
    2 1994  5.252 71.82825 102.5508333333333                 .
    2 1995   5.31 70.97126           105.725                 .
    2 1996  4.916 72.02213 102.8108333333333                 .
    2 1997  5.426 72.26086 97.42583333333333                 .
    2 1998   5.08        . 98.28666666666666                 .
    2 1999  7.703        . 96.70583333333333                 .
    2 2000  3.937 77.33924 92.70666666666666                 .
    2 2001  3.317 65.61207 93.37666666666667 65.93666239760651
    2 2002  4.467 64.00473 94.55416666666666 63.71109966331606
    2 2003  3.376 62.41528 98.50083333333333 62.21312533943776
    2 2004  3.076 60.49675            100.09 61.45107575621638
    2 2005  1.987 61.56726          100.1475  63.3030992600507
    2 2006  1.839 63.12274            99.665  65.5291813773315
    2 2007   1.49 64.98271 100.2616666666667 68.22671066468435
    2 2008  -.999 65.29819 102.7966666666667 62.34658576270689
    2 2009 -1.076 60.71798          102.7825 58.29042915456142
    2 2010  1.764 56.30419 99.99916666666667 56.49649890920445
    3 1990 -4.929 79.56224                 .                 .
    3 1991 -5.249 89.46034                 .                 .
    3 1992  -4.52  90.1946                 .                 .
    3 1993 -1.261 82.66838                 .                 .
    3 1994  1.059  70.6011 107.7766666666667                 .
    3 1995  4.111 60.80614 115.4816666666667                 .
    3 1996    3.8 57.76848 108.5391666666667                 .
    3 1997  5.066 52.15317            103.89                 .
    3 1998  5.014  48.7554 105.1966666666667                 .
    3 1999  5.148 51.21223 104.2616666666667                 .
    3 2000  7.544 51.37642            99.455                 .
    3 2001  8.056 52.55014 100.5308333333333 52.71872705394642
    3 2002  8.194 53.65681 101.8416666666667 55.49282811138554
    3 2003  4.636 57.47263 106.3008333333333 60.34215439832683
    3 2004  5.955 60.75411 106.1891666666667 63.83891668822606
    3 2005  3.209 65.50512 103.4358333333333  69.3722739632696
    3 2006  3.682 69.93976          102.1125 73.51894979549746
    3 2007  3.696 72.45432 103.3758333333333 76.47708270805641
    3 2008  2.087 78.00338 104.9683333333333  80.3294598654697
    3 2009  1.638 86.20117            105.96 86.64523363659966
    3 2010  1.093 86.04973               100 88.62640299305184
    4 1990  -.776 87.40244                 .                 .
    4 1991  -.486 91.28613                 .                 .
    4 1992   .273 91.90717                 .                 .
    4 1993   .694 91.47701                 .                 .
    4 1994   .585 86.16418 108.2483333333333                 .
    4 1995   .458 83.60825 110.5266666666667                 .
    4 1996  1.205  81.8323 109.5116666666667                 .
    4 1997  3.717 79.33855          104.3375                 .
    4 1998  3.688        .          105.4625                 .
    4 1999  4.433        . 102.8608333333333                 .
    4 2000  2.563 81.29047 97.34083333333334                 .
    4 2001  2.893 76.65136 97.10333333333334 76.97940296711415
    4 2002  2.063  75.5882           98.6575 76.07063620996594
    4 2003  1.517 74.99538 103.6716666666667 75.57212819792649
    4 2004  1.148 74.63783 105.4108333333333 76.61704476299853
    4 2005   .441 77.14659           104.005  80.1488755057605
    4 2006   .425 80.62109 103.2516666666667  84.2600523442078
    4 2007   .068 84.23831          103.6475 88.81464540322249
    4 2008  -.697 90.17921          104.0275 92.52507051867616
    4 2009  -.551  95.0137 103.8558333333333 95.06806884036641
    4 2010  -.629  94.1226 99.99833333333333 95.88490689819871
    5 1990  3.131 79.58484                 .                 .
    5 1991 -1.422 102.1866                 .                 .
    5 1992 -1.183  85.5144                 .                 .
    5 1993 -1.037 90.92883                 .                 .
    5 1994   -1.5 93.52699            116.06                 .
    5 1995 -1.246 95.66035 120.2458333333333                 .
    5 1996  -.676 100.2188          115.1325                 .
    5 1997   -.51 104.9116 108.8191666666667                 .
    5 1998  -.711 109.2212           110.015                 .
    5 1999 -1.422 115.5532 107.1408333333333                 .
    5 2000 -1.761  116.332 99.83083333333333                 .
    5 2001  -.368 111.1395 99.77083333333333 112.0403383011046
    5 2002  1.891 110.7516            100.83 110.8673423728782
    5 2003  1.414 109.8681 105.9033333333333 109.5191164282368
    5 2004   4.52 106.5218 107.4466666666667 106.0617364420291
    5 2005  4.673 104.4365          105.1075 104.8740905574438
    end
    label values country1 country1
    label def country1 1 "Austria", modify
    label def country1 2 "Belgium", modify
    label def country1 3 "Finland", modify
    label def country1 4 "France", modify
    label def country1 5 "Germany", modify
    After I declare a panel via -xtset- Stata does not recognise the unbalancedness as the software states the panel is strongly balanced

    Code:
    xtset country1 year
    Code:
     xtset country1 year
           panel variable:  country1 (strongly balanced)
            time variable:  year, 1990 to 2010
                    delta:  1 unit
    I assume I am doing something wrong with destring, but cannot find my mistake. Maybe someone can give me a hint? That would be very nice and appreciated.

    Best regards and stay healthy!

    Philipp
Working...
X