Announcement

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

  • reshape help requested

    I have 1200 companies, which are identified CIQ_IDs, for which I have data as follows. Further, I have a variable called each_co_id that identifies some variables within each CIQ_ID.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str12 CIQ_ID int each_co_id float(raw_return_2020 raw_return_2021 AbRet2020 AbRet2021) double(Vol1Yr_2020 Vol1Yr_2021) float(TobinQ2018 TobinQ2019 TobinQ2020 TobinQ2021 size2018 size2019 size2020 size2021 ROE2018 ROE2019 ROE2020 ROE2021)
    "IQ100231"   1 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"   2 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"   3 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"   4 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"   5 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"   6 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"   7 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"   8 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"   9 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  10 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  11 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  12 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  13 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  14 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  15 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  16 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  17 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  18 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  19 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  20 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  21 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  22 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  23 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  24 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  25 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  26 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  27 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  28 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  29 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  30 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  31 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  32 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  33 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  34 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  35 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  36 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  37 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  38 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  39 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  40 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  41 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  42 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  43 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  44 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  45 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  46 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  47 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  48 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  49 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  50 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  51 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  52 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  53 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  54 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  55 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  56 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  57 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  58 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  59 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  60 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  61 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  62 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  63 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  64 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  65 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  66 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  67 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  68 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  69 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  70 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  71 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  72 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  73 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  74 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  75 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  76 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  77 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  78 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  79 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  80 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  81 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  82 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  83 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  84 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  85 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  86 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  87 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  88 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  89 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  90 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  91 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  92 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  93 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  94 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  95 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  96 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  97 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  98 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231"  99 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    "IQ100231" 100 -.24423836 . -20.90623 . 33.2915 16.132 1.0444195 1.0801635 1.0901866 1.090187 12.04799 12.107318 12.053853 12.03685 .09325317 .06085936 -.02475494 .09293269
    end
    For some variables, I have data for the years 2021 & 2020 (raw_return, AbRet). However, for other variables I have data for the years 2021, 2020, 2019 & 2018 (Tobin'sQ, size, ROE and a whole lot more, but my version of Stata does not allow all the variables to be included in the dataex command. It gives me an error: input statement exceeds linesize limit. Try specifying fewer variables r(1000);.

    I want to reshape the data into long form. I gave the following command, but I am getting an error:

    reshape long raw_return_2020 raw_return_2021 AbRet2020 AbRet2021 Vol1Yr_2020 Vol1Yr_2
    > 021 TobinQ2018 TobinQ2019 TobinQ2020 TobinQ2021 size2018 size2019 size2020 size2021 R
    > OE2018 ROE2019 ROE2020 ROE2021 profitability2018 profitability2019 profitability2020
    > profitability2021 mtb2018 mtb2019 mtb2020 mtb2021 neg_mtb2018 neg_mtb2019 neg_mtb2020
    > neg_mtb2021 cash_over_assets2018 cash_over_assets2019 cash_over_assets2020 cash_over
    > _assets2021 stdebt_over_assets2018 stdebt_over_assets2019 stdebt_over_assets2020 stde
    > bt_over_assets2021 ltdebt_over_assets2018 ltdebt_over_assets2019 ltdebt_over_assets20
    > 20 ltdebt_over_assets2021 lev2018 lev2019 lev2020 lev2021 LTDebtFY2018 LTDebtFY2019 L
    > TDebtFY2020 LTDebtFY2021 TotalAssetsFY2018 TotalAssetsFY2019 TotalAssetsFY2020 TotalA
    > ssetsFY2021 ROAFY2018 ROAFY2019 ROAFY2020 ROAFY2021 CIQROE_FY2018 CIQROE_FY2019 CIQRO
    > E_FY2020 CIQROE_FY2021 TotalSalesFY2018 TotalSalesFY2019 TotalSalesFY2020 TotalSalesF
    > Y2021 AuditorFY2018 AuditorFY2019 AuditorFY2020 AuditorFY2021 AuditOpFY2018 AuditOpFY
    > 2019 AuditOpFY2020 AuditOpFY2021 ESGScrFY2021 ESGScrFY2020 ESGScrFY2019 ESGScrFY2018
    > ENVScrFY2021 ENVScrFY2020 ENVScrFY2019 ENVScrFY2018 SocialScrFY2021 SocialScrFY2020 S
    > ocialScrFY2019 SocialScrFY2018 GOVScrFY2021 GOVScrFY2020 GOVScrFY2019 GOVScrFY2018 Mk
    > tCapFY2018 MktCapFY2019 MktCapFY2020 MktCapFY2021 TotalDebtFY2018 TotalDebtFY2019 Tot
    > alDebtFY2020 TotalDebtFY2021 BVEquityFY2018 BVEquityFY2019 BVEquityFY2020 BVEquityFY2
    > 021 OperIncFY2018 OperIncFY2019 OperIncFY2020 OperIncFY2021 CashFY2018 CashFY2019 Cas
    > hFY2020 CashFY2021 STDebtFY2018 STDebtFY2019 STDebtFY2020 STDebtFY2021 NetIncFY2018 N
    > etIncFY2019 NetIncFY2020 NetIncFY2021 BVDebtFY2018 BVDebtFY2019 BVDebtFY2020 BVDebtFY
    > 2021, i(CIQ_ID) j(year)
    variable year contains all missing values
    r(498);

    I also tried splitting the above command into two, and, I get the same error.

    I do not understand what I am doing wrong. I would be very grateful for some help with reshaping my data.


  • #2
    When -reshape-ing to long layout, you do not write out the full names of the variables. You write out everything except the part that gives the -j()- variable, which, in your case is year. So, what you write in the -reshape- command must be stubs, not variable names. That accounts for the error message you got. But there is another error message awaiting you after you correct that. The variables CIQ_ID does not, uniquely identify observations in the data. To use -reshape- long, the -i()- option must specify a variable or set of variables that uniquely identifies observations in the data set. So you need to specify the -i()- option as -i(CIQ_ID each_do_id)-. (In some data sets there is no set of variables that does that, in which case you would have to create an identifier variable before proceeding.)

    Next there is the issue of creating a list of the stubs. One way is to just list them out. In the example data it would be:
    Code:
    reshape long raw_return_ AbRet Vol1Yr_ TobinQ size ROE, i(COQ_ID each_do_id) j(year)
    But it appears that in the real data set you have a very long list of these to deal with. And it would be easy to leave some out by mistake. So it is better to write a little code that will do it for you. The key to doing that is that every variable, you say, is available for 2020. (You could use 2021 the same way, it doesn't matter.) So the whole thing becomes:
    Code:
    ds *2020
    local stubs `r(varlist)'
    local stubs: subinstr local stubs "2020" "", all
    display `"`stubs'"'
    
    reshape long `stubs', i(CIQ_ID each_co_id) j(year)
    Added: Either way, there is some inconsistency in the variable names as to whether there is an underscore (_) character before the year. As a result, you end up with some new variables whose names end in an underscore. That's fine, but it would be a bit neater to eliminate that. So one last command to clean up that detail would be -rename *_ *-.
    Last edited by Clyde Schechter; 29 Jul 2022, 18:24.

    Comment


    • #3
      Dear Prof. Schechter,

      You have answered so may of my questions since I joined Statalist. Thank you very much for your continued support.

      I will try your suggestion asap.

      Comment


      • #4
        Dear Prof. Schechter,

        Your suggestion is Fantastic! Thank you so much for your quick response.

        My data is now reshaped and I can begin my analysis.

        Comment


        • #5
          See also https://www.stata.com/support/faqs/d...-with-reshape/ for the point that you need a list of stubs in problems like these.
          Last edited by Nick Cox; 30 Jul 2022, 03:18.

          Comment


          • #6
            Thank you so much, Prof. Cox. These articles are really useful for me.

            Comment

            Working...
            X