Announcement

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

  • reshape error

    Hi, I am trying to reshape from wide to long, but it keeps saying that "variable id does not uniquely identify the observations". I am not sure why the variable ID is not uniquely identified as I generated ID using the code:

    Code:
    gen seq = _n
    In full, this is what I coded and the error:
    Code:
    gen seq = _n
    foreach v of varlist exalus-exvzus {
    rename `v' u_`v'
    }
    
    reshape long u_, i(seq) j(country_pair_exchange) string
    (note: j = exalus exauus exbeus exbzus excaus exchus exdnus execus exeuus exfnus exfrus exgeus exgrus exhkus exinus exirus exitus exjpus exkous exmaus exmxus exneus exnous exnzus expous exsdus exsfus exsius exslus exspus exszus extaus exthus exukus exusal exusec exuseu exusir exusnz exusuk exvzus)
    
    variable id does not uniquely identify the observations
    Your data are currently wide.  You are performing a reshape long. You
    specified i(seq) and j(country_pair_exchange).  In the current wide form,
    variable seq should uniquely identify the observations.  Remember this picture:
    
    long                                wide
    
            +---------------+                   +------------------+
    
            | i   j   a   b |                   | i   a1 a2  b1 b2 |
    
            |---------------| <--- reshape ---> |------------------|
    
            | 1   1   1   2 |                   | 1   1   3   2  4 |
    
            | 1   2   3   4 |                   | 2   5   7   6  8 |
    
            | 2   1   5   6 |                   +------------------+
    
            | 2   2   7   8 |
    
            +---------------+
    
        Type reshape error for a list of the problem observations.
    
    r(9);
    The below are the data:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    
    clear
    
    input double date float year str32 hcomnam double(ret sprtrn u_exusal u_exalus u_exbzus u_excaus u_exchus u_exdnus u_exhkus u_exinus u_exjpus)
    
    14612 2000 "SELECT SECTOR SPDR TRUST"          -.019221041351556778 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "CBIZ INC"                          -.014814814552664757 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "P G & E CORP"                       -.03658536449074745 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "E C I TELECOM LTD"                 -.003952569328248501 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "ISHARES INC"                         .01937984488904476 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "P P L CORP"                        -.030054645612835884 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "TARRAGON CORP NEV"                 -.012195121496915817 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "VICOR CORPORATION"                 -.027006173506379128 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "D R S TECHNOLOGIES INC"             -.03896103799343109 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "PLAINS RESOURCES INC"               -.05999999865889549 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "WEST COAST BANCORP ORE NEW"         .004629629664123058 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "NATIONAL BANKSHARES INC"            .012658228166401386 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "AMERICAN WATER WORKS INC"            -.0117647061124444 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "CALIFORNIA WATER SERVICE GROUP"     -.07422680407762527 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "BANK ONE CORP"                               -.02734375 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "AMWEST INSURANCE GROUP INC"                           0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "IVOW INC"                            .17499999701976776 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "MODTECH HOLDINGS INC"                .02083333395421505 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "IMPATH INC"                         .007371007464826107 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "MOORE WALLACE INC"                                    0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "PRIVATE MEDIA GROUP INC"              .0347222238779068 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "HEARTPORT INC"                       .07894736528396606 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "STRATEGIC GLOBAL INCOME FUND INC"                .03125 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "CENTER TRUST INC"                   -.05806451663374901 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "AVIGEN INC"                       -.0030241934582591057 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "JO ANN STORES INC"                                    0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "STONEX GROUP INC"                  -.024390242993831635 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "TECH DATA CORP"                      -.0276497695595026 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "P C C GROUP INC"                     .23076923191547394 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "PLEXUS CORP"                       -.017045455053448677 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "STATEWIDE FINANCIAL CORP"          -.024752475321292877 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "MORGAN STANLEY TRUSTS"                                0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "SOUTHDOWN INC"                      -.04116222634911537 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "R P M INTERNATIONAL INC"           -.030674846842885017 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "MCRAE INDUSTRIES INC"                                 0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "RENAISSANCE LEARNING INC"           .044692736119031906 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "POTTERS FINANCIAL CORP"              .05263157933950424 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "KRATOS DEFENSE & SECUR SOLS INC"     .03295128792524338 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "PACIFIC GATEWAY PPTYS INC MD"                         0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "INTEGRITY MEDIA INC"                 .03999999910593033 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "SELECT SECTOR SPDR TRUST"          -.012211669236421585 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "ABERDEEN ASIA PACIFIC INCOME FD"     .02469135820865631 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "THERMO INSTRUMENT SYSTEMS INC"                        0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "FIRST REGIONAL BANCORP"                               0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "MORTON INDUSTRIAL GROUP INC"                          0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "USURF AMERICA INC"                   .10294117778539658 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "ARCH CAPITAL GROUP LTD NEW"          -.0891089141368866 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "CAPSULE COMMUNICATIONS INC"          .02500000037252903 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "FEDDERS CORP"                       .022727273404598236 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "M C N ENERGY GROUP INC"            -.021052632480859756 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "FIELDWORKS INCORPORATED"                              0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "C T O REALTY GROWTH INC"           -.019607843831181526 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "EMVELCO CORP"                         .0810810774564743 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "L V M H MOET HENNESSY VUITTON"     -.012362637557089329 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "C B L & ASSOCIATES PPTYS INC"     -.0060606058686971664 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "BANKUNITED FINANCIAL CORP"          -.10236220806837082 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "NASHUA CORP"                         .01666666753590107 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "AMERITRANS CAPITAL CORP"            -.05511811003088951 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "THORATEC CORP"                      -.06410256773233414 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "JOURNAL REGISTER CO"                -.04048582911491394 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "NORTHERN TRUST CORP"                -.04775943234562874 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "STOLT NIELSEN S A"                  .035087719559669495 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "CAROLINA SOUTHERN BK SPARTANBURG"    .03365384787321091 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "WORLD FUEL SERVICES CORP"                             0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "HOME STAKE OIL & GAS CO"                              0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "CAPTEC NET LEASE REALTY INC"         .03333333507180214 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "ACMAT CORP"                                           0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "BLACKROCK MUNIHLDGS NJ QLTY FD"     .005434782709926367 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "CADILLAC FAIRVIEW CORP"             .010869565419852734 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "ATRION CORP"                                          0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "T J INTERNATIONAL INC"            -.0007440476329065859 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "SYNTHETECH INC"                      .05000000074505806 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "D I S C INC"                        -.03030303120613098 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "CONCERO INC"                       .0031347961630672216 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "TRIPOS INC"                         -.03804347664117813 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "MARKETING SPECIALISTS CORP"                           0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "KOLLMORGEN CORP"                   -.025380710139870644 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "A D C TELECOMMUNICATIONS INC"      -.000861326465383172 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "INTERLEAF INC"                      -.00929368007928133 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "EVANS & SUTHERLAND COMPUTER CORP"    .08743169158697128 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "CINTAS CORP"                       -.016470588743686676 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "AZUREL LTD"                          .06060606241226196 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "COHERENT INC"                       -.02570093423128128 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "T ROWE PRICE GROUP INC"            -.049069374799728394 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "E D P ENERGIAS DE PORTUGAL S A"     -.00358422938734293 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "INSIGHT HEALTH SERVICES CORP"         .1428571492433548 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "RELIANCE GROUP HOLDINGS INC"         .06603773683309555 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "RICHARDSON ELECTRONICS LTD"         -.03333333507180214 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "ENGLOBAL CORP"                        .0714285746216774 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "BANK GRANITE CORP"                  -.06104651093482971 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "EASTERN ENTERPRISES"               -.007616974879056215 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "ZIEGLER COMPANY INC"               -.012552301399409771 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "MERCHANTS NEW YORK BANCORP INC"    -.007299270015209913 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "PENN AMERICA GROUP INC"                               0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "PAIRGAIN TECHNOLOGIES INC"          -.04845815151929855 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "BROOKDALE LIVING COMM INC"          -.04040404036641121 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "D V I INC"                          -.02469135820865631 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "LIBERTY BANCORP INC NJ"                               0 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "ERICSSON"                            .03615604341030121 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    14612 2000 "COMVERSE TECHNOLOGY INC"             .06347150355577469 -.009549090000000001 .6591 1.5172204521316948 1.805 1.4465 8.2798 7.329 7.7765 43.55 101.7
    
    end
    
    format %td date
    I typed in reshape error for the list of problem observations and it says "16928310 of 37899830 observations have duplicate i values". However, even after dropping the duplicates, it is still not working.

    I am trying to achieve an output file with firm-year-country(host)-exchange_rates_coefficient-level and I was recommended to reshape the data from wide to long first. Am I writing the -reshape- command wrongly?
    Last edited by Kye Reen; 30 Jul 2021, 17:16.

  • #2
    I was not able to reproduce that error. I used this codes and it was reshaped to long:
    Code:
    gen seq = _n
    
    reshape long u_, i(seq) j(country_pair_exchange, string)

    Comment


    • #3
      Hi Ken, I tried your code and it is still giving me the same error

      Comment


      • #4
        You have been bitten by a precision problem.

        When you write -gen seq = _n-, by default, seq is created with float storage type. For sufficiently small data sets (including most data sets that most people would consider large), this is not a problem. But you have over 37,800,000 observations, and a float does not have enough bits to count that high without losing precision. Floats are only accurate to about 7 digits. Your larger values of seq require 8 digits. And, as the message sort of implies, once it counts up about half way through the data set, it starts cycling through the numbers again.

        So you need to force Stata to give you a seq variable with more precision.

        Code:
        gen long seq = _n
        will give you the needed precision. (Longs and floats are both only 4 bytes, but some of the bits in a float are reserved for the exponent, and these expand the range of floats at the expense of precision. Longs use all of the bits, except one sign bit, for precision. They can represent 9 digits of precision.)

        I've been bitten by this a few times over the years myself. I no longer run into this problem because I have just made it a regular habit to always generate observation counters as longs. If you had a data set with more observations than can be represented in 9 digits (i.e. a trillion observations) then you would need to go to a double. But I have never worked with a data set that huge, and I suspect if I did, this particular issue would be the least of the difficulties I encounter.

        Added: Let me anticipate your next post. After you make this correction, Stata will appear to be "hung" processing the -reshape-. -reshape-ing a data set this large is going to be very slow. You will begin to wonder if your grandchildren will live to see the end of it. There are user-written commands that do this much faster than StataCorp's official -reshape- command. One is Rafal Raciborski's -tolong-, available from SSC. It is much, much faster.
        Last edited by Clyde Schechter; 30 Jul 2021, 18:51.

        Comment


        • #5
          Hi Clyde, yes it did take some time but I received this error message:

          Code:
          I/O error writing .dta file    
          Usually such I/O errors are caused by the disk or file system being full. r(693);
          I've tried deleting most unused big files even on the temp directory but it is still no use. I was thinking to maybe try using the -tolong- command and see if it works? When using the -tolong- command, in this case, is it just:

          Code:
          tolong u_, i(seq) j(country-pair-exchange) string

          Comment


          • #6
            No, not exactly. -tolong- has a slightly different syntax. There is no -string- option for the -j()- variable. Instead you use @ in the stubname. In your case it would be
            Code:
            tolong u_@, i(seq) j(country_pair_exchange)
            I do not know if this will get around your file system overflow error. I don't know how -tolong- uses disk space. Try it and see.

            If you still run into a file system error, then there are two possibilities:

            1. The end result file may be too large to fit in your file system. Remember that a long layout data set will be larger than the correspoding wide layout. In this case you may have to talk to your system administrator about getting more space allocated to you. There will be no solution to this problem within Stata.

            2. The end result may be fine, but some intermediate file built along the way may be too large. In that case, I would first remove any variables that you will not need going forward from the data set. And if that doesn't solve the problem, then I would break the data set up into chunks, apply -tolong- separately to each, and then -append- all the results. David Elliott's -chunky-, available from SSC, can help you break up the data set.

            Comment


            • #7
              I tried the -tolong- code and it says

              Code:
              tolong u_@, i(seq) j(country_pair_ex)
              
                               <istmt>:  3499  _tolong() not found
              
              r(3499);

              Comment


              • #8
                I'm afraid I don't know how to deal with that. It's a Mata runtime error, and I don't know why that function is not found. It may be that your installation of -tolong- was not complete. The best I can suggest is to uninstall -tolong- (ssc uninstall tolong), then re-install it (ssc install tolong). Reboot your computer and then try it again.

                Comment

                Working...
                X