Announcement

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

  • repeated time values within panel

    Hi all,

    I have sectoral data (isiccomb1) per year and country. I am getting the error message "repeated time values within panel" . When I try:

    egen country_sector=group(country isiccomb1)

    or

    egen country_year=group(country year)

    I still keep getting the same error of repeated time values within panel. I know I could simply ignore the time component but I need to construct leads (forward lags) on my regressions. Please, see the dataex of my data. Countries are coded by number as well as sector (isiccomb1)

    dataex country year isic isiccomb sourcecode Establishments Employment Wages Output GrossFixedCapital ValueAdded F
    > emaleEmployees logoutputperworker

    ----------------------- copy starting from the next line -----------------------
    [/CODE]
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(country year) str2 isic str3 isiccomb byte sourcecode long(Establishments Employment) double(Wages Output GrossFixedCapital ValueAdded) long FemaleEmployees float logoutputperworker
    32 1963 "15" "15" 3 . 248175 . . . . . .
    36 1963 "15" "15" 3 . 122000 288960046 2279200365 96320015 679840109 . 9.835314
    40 1963 "15" "15" 3 . 59988 96077045 767038159 . 239346089 . 9.456147
    56 1963 "15" "15" 3 . 108000 170999977 2914399565 96800401 651600525 . 10.203043
    76 1963 "15" "15" 3 . 293000 . . . . . .
    100 1963 "15" "15" 3 . 102000 50454000 . 11950000 . . .
    124 1963 "15" "15" 3 . 211000 787194232 5878458694 148352270 1835859340 . 10.234947
    152 1963 "15" "15" 3 . 42670 43156597 561035758 16029593 215782984 . 9.484044
    170 1963 "15" "15" 3 . 53600 51333333 739777778 14888889 281666667 . 9.532556
    188 1963 "15" "15" 3 . 9604 7983396 116981132 3482264 37766038 . 9.407588
    196 1963 "15" "15" 3 . 3268 3659599 41028388 . 11292397 . 9.437841
    200 1963 "15" "15" 3 . 181000 180246914 2003086420 . . . 9.311703
    208 1963 "15" "15" 3 . 51900 130444728 844054124 . 257704347 . 9.696653
    214 1963 "15" "15" 3 . 98820 63985000 2.789e+08 . 119180000 . 7.945309
    218 1963 "15" "15" 3 . 10793 8577777 98166670 6916667 37833340 . 9.115524
    222 1963 "15" "15" 3 . 20261 9028000 1.348e+08 . 37372000 . 8.80285
    246 1963 "15" "15" 3 . 48200 88437220 1181250128 . 221874355 . 10.106725
    250 1963 "15" "15" 3 . 447330 . 8660415864 . 1702026174 . 9.870976
    266 1963 "15" "15" 3 . 318 . 1363174 . . . 8.363275
    278 1963 "15" "15" 3 . 192600 . 4427499355 . . . 10.04273
    280 1963 "15" "15" 3 . 477000 947499668 9649998435 . 4424999315 . 9.914952
    288 1963 "15" "15" 3 . 3751 2394366 27225352 661972 14816901 . 8.889881
    300 1963 "15" "15" 3 . 39440 30429005 381004305 15504140 85664634 . 9.175785
    340 1963 "15" "15" 3 . 4386 3900500 35965000 . 17775000 . 9.011884
    348 1963 "15" "15" 3 . 138000 105068143 1675894378 59028961 355195911 . 9.404604
    356 1963 "15" "15" 3 . 573000 129360129 2837522838 . 354270354 . 8.507556
    364 1963 "15" "15" 3 . 24934 11590759 174021914 11287129 63712211 . 8.850704
    368 1963 "15" "15" 3 . 11840 7741997 102843959 . 30043988 . 9.069485
    372 1963 "15" "15" 3 . 46300 72241652 627199114 29930890 158201721 . 9.513877
    376 1963 "15" "15" 3 . 23820 32333333 3.040e+08 14440000 91333333 . 9.454257
    388 1963 "15" "15" 3 . 13834 24639990 187319925 . 67059973 . 9.513444
    392 1963 "15" "15" 3 . 1072000 647222222 7888888889 363888889 2430555556 . 8.903685
    400 1963 "15" "15" 3 . 5258 1397199 23948390 . 5370398 . 8.423905
    404 1963 "15" "15" 3 . 11616 10362796 105053158 . 22044391 . 9.1098385
    410 1963 "15" "15" 3 . 47500 13846154 233846154 16923077 84615385 . 8.501689
    470 1963 "15" "15" 3 . 2359 1786400 16976400 1178800 4776800 . 8.881342
    508 1963 "15" "15" 3 . . 6886957 65808696 . . . .
    528 1963 "15" "15" 3 . 172000 298342834 3646409778 133425540 616022315 . 9.96176
    554 1963 "15" "15" 3 . 38840 112556556 951064664 29129831 199946051 . 10.105886
    558 1963 "15" "15" 3 . . . 97342857 . 42100000 . .
    566 1963 "15" "15" 3 . 7720 5073598 52891979 . 35531986 . 8.832192
    578 1963 "15" "15" 3 . 47800 101499959 968799612 33179987 219799912 . 9.916787
    586 1963 "15" "15" 3 . 31383 8898339 218581659 . 56307986 . 8.848649
    590 1963 "15" "15" 3 . 4643 7860000 64340000 2675000 24740000 . 9.536576
    598 1963 "15" "15" 3 . 1201 290080 2458400 . 930720 . 7.624112
    600 1963 "15" "15" 3 . . . . . 31768667 . .
    608 1963 "15" "15" 3 . 73100 39381929 561064621 16775679 247287825 . 8.945763
    616 1963 "15" "15" 3 . 370000 . . . 1.013e+09 . .
    620 1963 "15" "15" 3 . 37000 . 274092773 . 90394968 . 8.910304
    630 1963 "15" "15" 3 . 21141 . . . . . .
    642 1963 "15" "15" 3 . 129000 79618889 . . . . .
    702 1963 "15" "15" 3 . 6510 5128674 51940076 499801 14046687 . 8.984507
    710 1963 "15" "15" 3 . 119000 114799954 1139599544 27047989 324799870 . 9.167064
    716 1963 "15" "15" 3 . 14354 . . . . . .
    724 1963 "15" "15" 3 . 246000 113833065 1983336430 . 323335376 . 8.99496
    752 1963 "15" "15" 3 . 70400 207414739 2085745601 . 516120552 . 10.296444
    760 1963 "15" "15" 3 . 25700 7657068 71727749 . 16649215 . 7.934142
    788 1963 "15" "15" 3 . 8411 8026190 101357143 2833333 22857143 . 9.396865
    792 1963 "15" "15" 3 . 53350 38333333 636666667 25888889 165555556 . 9.387128
    800 1963 "15" "15" 3 . 11273 5164217 113251995 855383 11621728 . 9.21496
    810 1963 "15" "15" 3 . 2220000 2368888889 . . . . .
    826 1963 "15" "15" 3 . 718000 1310399476 10275995890 369599852 3331998667 . 9.568851
    840 1963 "15" "15" 3 . 1643000 8.640e+09 6.861e+10 1.250e+09 2.182e+10 . 10.63967
    862 1963 "15" "15" 3 . 39100 73731343 774328358 . 299701493 . 9.893629
    890 1963 "15" "15" 3 . 107000 40800000 . . 1.492e+08 . .
    894 1963 "15" "15" 3 . 4163 3893557 36414566 . 10112045 . 9.0764885
    32 1964 "15" "15" 3 . 263743 . . . . . .
    36 1964 "15" "15" 3 . 126000 309120049 2500960400 100800016 747040120 . 9.895904
    40 1964 "15" "15" 3 . 59123 99230799 840268876 . 261807659 . 9.561857
    56 1964 "15" "15" 3 . 109000 188799549 3226279339 102599664 700599773 . 10.295492
    76 1964 "15" "15" 3 . 314000 . . . . . .
    100 1964 "15" "15" 3 . 102300 52677000 . 15600000 . . .
    124 1964 "15" "15" 3 . 215000 839979306 6332294330 164101917 2002599671 . 10.290535
    152 1964 "15" "15" 3 . 44110 43346337 593844820 212397052 234070221 . 9.507687
    170 1964 "15" "15" 3 . 54800 60000000 986333333 21666667 342555556 . 9.798059
    188 1964 "15" "15" 3 . . . . . 41418868 . .
    196 1964 "15" "15" 3 . 3094 3791198 43626787 . 12235997 . 9.553962
    200 1964 "15" "15" 3 . 181000 183950617 2338271605 . . . 9.466426
    208 1964 "15" "15" 3 . 55200 146949389 980145183 . 293898777 . 9.784493
    214 1964 "15" "15" 3 . 87050 81004000 310360000 . 122050000 . 8.179006
    218 1964 "15" "15" 3 . 10844 9261111 113111110 6955556 42166670 . 9.252514
    222 1964 "15" "15" 3 . 20795 10808000 1.716e+08 . 39796000 . 9.0182085
    246 1964 "15" "15" 3 . 48500 99375512 1293750848 . 243749083 . 10.191492
    250 1964 "15" "15" 3 . 455300 . 9893945393 . 1976682389 . 9.986477
    266 1964 "15" "15" 3 . 411 . 4705600 . . . 9.345671
    278 1964 "15" "15" 3 . 190700 . 4592499003 . . . 10.089233
    280 1964 "15" "15" 3 . 475000 1022499863 10499998044 468749756 4815749122 . 10.00357
    288 1964 "15" "15" 3 . 4342 2774648 28619718 647887 16070423 . 8.793516
    300 1964 "15" "15" 3 . 41590 34165900 464329119 14731773 97670404 . 9.320489
    340 1964 "15" "15" 3 . 4417 4371500 43120000 . 21175000 . 9.186281
    348 1964 "15" "15" 3 . 142000 113032368 1851788756 72061329 390119250 . 9.475836
    356 1964 "15" "15" 3 . 599000 146790147 3179823180 . 400470400 . 8.577074
    364 1964 "15" "15" 3 . 26738 12514851 225493465 16686469 84432475 . 9.039961
    368 1964 "15" "15" 3 . 13260 8615597 112419955 . 32955987 . 9.045245
    372 1964 "15" "15" 3 . 46400 80919030 674800101 29483238 168559445 . 9.584872
    376 1964 "15" "15" 3 . 25700 39000000 363333333 20223333 103333333 . 9.556585
    388 1964 "15" "15" 3 . 14323 24499990 186479925 . 69159972 . 9.474213
    392 1964 "15" "15" 3 . 1080000 744444444 8758333333 383333333 2572222222 . 9.0008
    400 1964 "15" "15" 3 . 5673 1657599 22027591 . 5535598 . 8.264333
    404 1964 "15" "15" 3 . 12659 11849595 106310357 . 24735190 . 9.035749
    end
    [/CODE]
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 141631 observations
    Use the count() option to list more

    Thank you so much,




  • #2

    Code:
     * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(country year) str2 isic str3 isiccomb byte sourcecode long(Establishments Employment) double(Wages Output GrossFixedCapital ValueAdded) long FemaleEmployees float logoutputperworker
    32 1963 "15" "15" 3 . 248175 . . . . . .
    36 1963 "15" "15" 3 . 122000 288960046 2279200365 96320015 679840109 . 9.835314
    40 1963 "15" "15" 3 . 59988 96077045 767038159 . 239346089 . 9.456147
    56 1963 "15" "15" 3 . 108000 170999977 2914399565 96800401 651600525 . 10.203043
    76 1963 "15" "15" 3 . 293000 . . . . . .
    100 1963 "15" "15" 3 . 102000 50454000 . 11950000 . . .
    124 1963 "15" "15" 3 . 211000 787194232 5878458694 148352270 1835859340 . 10.234947
    152 1963 "15" "15" 3 . 42670 43156597 561035758 16029593 215782984 . 9.484044
    170 1963 "15" "15" 3 . 53600 51333333 739777778 14888889 281666667 . 9.532556
    188 1963 "15" "15" 3 . 9604 7983396 116981132 3482264 37766038 . 9.407588
    196 1963 "15" "15" 3 . 3268 3659599 41028388 . 11292397 . 9.437841
    200 1963 "15" "15" 3 . 181000 180246914 2003086420 . . . 9.311703
    208 1963 "15" "15" 3 . 51900 130444728 844054124 . 257704347 . 9.696653
    214 1963 "15" "15" 3 . 98820 63985000 2.789e+08 . 119180000 . 7.945309
    218 1963 "15" "15" 3 . 10793 8577777 98166670 6916667 37833340 . 9.115524
    222 1963 "15" "15" 3 . 20261 9028000 1.348e+08 . 37372000 . 8.80285
    246 1963 "15" "15" 3 . 48200 88437220 1181250128 . 221874355 . 10.106725
    250 1963 "15" "15" 3 . 447330 . 8660415864 . 1702026174 . 9.870976
    266 1963 "15" "15" 3 . 318 . 1363174 . . . 8.363275
    278 1963 "15" "15" 3 . 192600 . 4427499355 . . . 10.04273
    280 1963 "15" "15" 3 . 477000 947499668 9649998435 . 4424999315 . 9.914952
    288 1963 "15" "15" 3 . 3751 2394366 27225352 661972 14816901 . 8.889881
    300 1963 "15" "15" 3 . 39440 30429005 381004305 15504140 85664634 . 9.175785
    340 1963 "15" "15" 3 . 4386 3900500 35965000 . 17775000 . 9.011884
    348 1963 "15" "15" 3 . 138000 105068143 1675894378 59028961 355195911 . 9.404604
    356 1963 "15" "15" 3 . 573000 129360129 2837522838 . 354270354 . 8.507556
    364 1963 "15" "15" 3 . 24934 11590759 174021914 11287129 63712211 . 8.850704
    368 1963 "15" "15" 3 . 11840 7741997 102843959 . 30043988 . 9.069485
    372 1963 "15" "15" 3 . 46300 72241652 627199114 29930890 158201721 . 9.513877
    376 1963 "15" "15" 3 . 23820 32333333 3.040e+08 14440000 91333333 . 9.454257
    388 1963 "15" "15" 3 . 13834 24639990 187319925 . 67059973 . 9.513444
    392 1963 "15" "15" 3 . 1072000 647222222 7888888889 363888889 2430555556 . 8.903685
    400 1963 "15" "15" 3 . 5258 1397199 23948390 . 5370398 . 8.423905
    404 1963 "15" "15" 3 . 11616 10362796 105053158 . 22044391 . 9.1098385
    410 1963 "15" "15" 3 . 47500 13846154 233846154 16923077 84615385 . 8.501689
    470 1963 "15" "15" 3 . 2359 1786400 16976400 1178800 4776800 . 8.881342
    508 1963 "15" "15" 3 . . 6886957 65808696 . . . .
    528 1963 "15" "15" 3 . 172000 298342834 3646409778 133425540 616022315 . 9.96176
    554 1963 "15" "15" 3 . 38840 112556556 951064664 29129831 199946051 . 10.105886
    558 1963 "15" "15" 3 . . . 97342857 . 42100000 . .
    566 1963 "15" "15" 3 . 7720 5073598 52891979 . 35531986 . 8.832192
    578 1963 "15" "15" 3 . 47800 101499959 968799612 33179987 219799912 . 9.916787
    586 1963 "15" "15" 3 . 31383 8898339 218581659 . 56307986 . 8.848649
    590 1963 "15" "15" 3 . 4643 7860000 64340000 2675000 24740000 . 9.536576
    598 1963 "15" "15" 3 . 1201 290080 2458400 . 930720 . 7.624112
    600 1963 "15" "15" 3 . . . . . 31768667 . .
    608 1963 "15" "15" 3 . 73100 39381929 561064621 16775679 247287825 . 8.945763
    616 1963 "15" "15" 3 . 370000 . . . 1.013e+09 . .
    620 1963 "15" "15" 3 . 37000 . 274092773 . 90394968 . 8.910304
    630 1963 "15" "15" 3 . 21141 . . . . . .
    642 1963 "15" "15" 3 . 129000 79618889 . . . . .
    702 1963 "15" "15" 3 . 6510 5128674 51940076 499801 14046687 . 8.984507
    710 1963 "15" "15" 3 . 119000 114799954 1139599544 27047989 324799870 . 9.167064
    716 1963 "15" "15" 3 . 14354 . . . . . .
    724 1963 "15" "15" 3 . 246000 113833065 1983336430 . 323335376 . 8.99496
    752 1963 "15" "15" 3 . 70400 207414739 2085745601 . 516120552 . 10.296444
    760 1963 "15" "15" 3 . 25700 7657068 71727749 . 16649215 . 7.934142
    788 1963 "15" "15" 3 . 8411 8026190 101357143 2833333 22857143 . 9.396865
    792 1963 "15" "15" 3 . 53350 38333333 636666667 25888889 165555556 . 9.387128
    800 1963 "15" "15" 3 . 11273 5164217 113251995 855383 11621728 . 9.21496
    810 1963 "15" "15" 3 . 2220000 2368888889 . . . . .
    826 1963 "15" "15" 3 . 718000 1310399476 10275995890 369599852 3331998667 . 9.568851
    840 1963 "15" "15" 3 . 1643000 8.640e+09 6.861e+10 1.250e+09 2.182e+10 . 10.63967
    862 1963 "15" "15" 3 . 39100 73731343 774328358 . 299701493 . 9.893629
    890 1963 "15" "15" 3 . 107000 40800000 . . 1.492e+08 . .
    894 1963 "15" "15" 3 . 4163 3893557 36414566 . 10112045 . 9.0764885
    32 1964 "15" "15" 3 . 263743 . . . . . .
    36 1964 "15" "15" 3 . 126000 309120049 2500960400 100800016 747040120 . 9.895904
    40 1964 "15" "15" 3 . 59123 99230799 840268876 . 261807659 . 9.561857
    56 1964 "15" "15" 3 . 109000 188799549 3226279339 102599664 700599773 . 10.295492
    76 1964 "15" "15" 3 . 314000 . . . . . .
    100 1964 "15" "15" 3 . 102300 52677000 . 15600000 . . .
    124 1964 "15" "15" 3 . 215000 839979306 6332294330 164101917 2002599671 . 10.290535
    152 1964 "15" "15" 3 . 44110 43346337 593844820 212397052 234070221 . 9.507687
    170 1964 "15" "15" 3 . 54800 60000000 986333333 21666667 342555556 . 9.798059
    188 1964 "15" "15" 3 . . . . . 41418868 . .
    196 1964 "15" "15" 3 . 3094 3791198 43626787 . 12235997 . 9.553962
    200 1964 "15" "15" 3 . 181000 183950617 2338271605 . . . 9.466426
    208 1964 "15" "15" 3 . 55200 146949389 980145183 . 293898777 . 9.784493
    214 1964 "15" "15" 3 . 87050 81004000 310360000 . 122050000 . 8.179006
    218 1964 "15" "15" 3 . 10844 9261111 113111110 6955556 42166670 . 9.252514
    222 1964 "15" "15" 3 . 20795 10808000 1.716e+08 . 39796000 . 9.0182085
    246 1964 "15" "15" 3 . 48500 99375512 1293750848 . 243749083 . 10.191492
    250 1964 "15" "15" 3 . 455300 . 9893945393 . 1976682389 . 9.986477
    266 1964 "15" "15" 3 . 411 . 4705600 . . . 9.345671
    278 1964 "15" "15" 3 . 190700 . 4592499003 . . . 10.089233
    280 1964 "15" "15" 3 . 475000 1022499863 10499998044 468749756 4815749122 . 10.00357
    288 1964 "15" "15" 3 . 4342 2774648 28619718 647887 16070423 . 8.793516
    300 1964 "15" "15" 3 . 41590 34165900 464329119 14731773 97670404 . 9.320489
    340 1964 "15" "15" 3 . 4417 4371500 43120000 . 21175000 . 9.186281
    348 1964 "15" "15" 3 . 142000 113032368 1851788756 72061329 390119250 . 9.475836
    356 1964 "15" "15" 3 . 599000 146790147 3179823180 . 400470400 . 8.577074
    364 1964 "15" "15" 3 . 26738 12514851 225493465 16686469 84432475 . 9.039961
    368 1964 "15" "15" 3 . 13260 8615597 112419955 . 32955987 . 9.045245
    372 1964 "15" "15" 3 . 46400 80919030 674800101 29483238 168559445 . 9.584872
    376 1964 "15" "15" 3 . 25700 39000000 363333333 20223333 103333333 . 9.556585
    388 1964 "15" "15" 3 . 14323 24499990 186479925 . 69159972 . 9.474213
    392 1964 "15" "15" 3 . 1080000 744444444 8758333333 383333333 2572222222 . 9.0008
    400 1964 "15" "15" 3 . 5673 1657599 22027591 . 5535598 . 8.264333
    404 1964 "15" "15" 3 . 12659 11849595 106310357 . 24735190 . 9.035749
    end
    ------------------ copy up to and including the previous line ------------------

    Comment


    • #3
      Your example data does not exhibit the problem you speak of.

      Code:
      . egen panel = group(country isiccomb)
      
      . xtset panel year
      
      Panel variable: panel (unbalanced)
       Time variable: year, 1963 to 1964
               Delta: 1 unit
      As you can see, this code runs without error message or interruption and leads to successful declaration of panel data variables, which will enable you to use lags and leads, etc.

      I assume that your full data set, however, is different. In order to get help, you need to show an example of data that exhibits the problem you are trying to solve. You can identify the offending observations as follows:

      Code:
      duplicates tag country isiccomb year, gen(flag)
      browse if flag
      This will show you the observations that are causing you to get those repeated value messages. If after examining these offending observations you cannot see how to fix the problem, do post back with a different data example that includes some or all of the offending observations. Somebody might be able to then see what needs to be done, or at least to point you in the right direction for fixing your pathological data set.

      Added: Crossed with #2. But the problem doesn't arise in the data set posted there either, so my remarks still apply.
      Last edited by Clyde Schechter; 07 Oct 2021, 14:30.

      Comment


      • #4
        Thank you! Again, I was having duplicates. The data comes from many sources and sometimes the same values from different sources!

        Comment


        • #5
          Yes, that can be a problem when data from multiple sources are combined.

          In your workflow, you should, when you combine two data sources that have the potential to lead to duplicates, check for that at the time you combine them, and if you find any, eliminate them at that point. If you make that a habit, you will not continually run into problems like this (and other problems that will arise with duplicate observations.) Indeed, the worst problems caused by duplicates are the ones that don't give you an error message, because they are producing incorrect results and giving you no warning! Those error messages from -reshape- and -xtset- are there to protect you from that. That's Stata being helpful. But better still is to prevent them by thoroughly scrubbing the data sets as you build them, so that you can analyze them without worrying.

          Comment


          • #6
            Exactly! I am creating three separate datasets categorizing them by source. Now, I am getting reasonable results! Thank you so much for your help!

            Comment

            Working...
            X