Announcement

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

  • Creating a panel from excel

    Dear All,

    I have data in the excel file which doesn't look like a panel. In the first column I have time. In the next 5 columns I have the same indicator for 5 different companies. Is it possible to tell stata to create 1 column for company names and 1 columns for this indicator so that I have a panel. I'm trying to do the panel in excel but it is very time consuming since the time span is very large

  • #2
    This is likely a -reshape- problem, but it is difficult to give more specific advice without a sample of your data. After importing your Excel file into Stata using the -import excel- command, please use the dataex command to generate a sample of your data, and paste it in a reply to this post.

    Comment


    • #3
      Thank you for your answer. My data is sensitive. Therefore I created an example. Some indicators are 0 and it is not a missing value. Data contains missing values denoted as "."

      I tried a command
      reshape long Ind, i(Time) j(Company)

      so that I have panel and indicators for each company. However I saw :variable Company contains all missing values

      I replaced all missing indicators with a value 100. I thought once I have a panel I can replace them again. But still encounter this problem.


      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input int Time double(IndA IndB IndC)
      14976  .43                .   0
      14977  .44                .   0
      14978  .45                .   0
      14979  .46                .   .
      14980  .47                .   .
      14981  .48                .   .
      14982  .49                .   .
      14983   .5              .23   .
      14984  .51              .23   .
      14985  .52              .23   .
      14986  .53              .23   .
      14987  .54              .23   .
      14988  .55              .24   .
      14989  .56              .25   .
      14990  .57              .26   .
      14991  .58              .27   .
      14992  .59              .28   .
      14993   .6              .29   .
      14994  .61               .3   .
      14995  .62              .31   .
      14996  .63              .32   .
      14997  .64              .33   .
      14998  .65              .34   .
      14999  .66              .35   .
      15000  .67              .36   .
      15001  .68              .37   .
      15002  .69              .38   .
      15003   .7              .39   .
      15004  .71               .4   .
      15005  .72              .41   .
      15006  .73              .42   .
      15007  .74              .43   .
      15008  .75              .44   .
      15009  .76              .45 .31
      15010  .77              .46 .32
      15011  .78              .47 .33
      15012  .79              .48 .34
      15013   .8              .49 .35
      15014  .81 .499999999999999 .36
      15015  .82 .509999999999999 .37
      15016  .83 .519999999999999 .38
      15017  .84 .529999999999999 .39
      15018  .85 .539999999999999  .4
      15019  .86 .549999999999999 .41
      15020  .87 .559999999999999 .42
      15021  .88 .569999999999999 .43
      15022  .89 .579999999999999 .44
      15023   .9 .589999999999999 .45
      15024  .91 .599999999999999 .46
      15025  .92 .609999999999999 .47
      15026  .93 .619999999999999 .48
      15027  .94 .629999999999999 .49
      15028  .95 .639999999999999  .5
      15029  .96 .649999999999999 .51
      15030  .97 .659999999999999 .52
      15031  .98 .669999999999999 .53
      15032  .99 .679999999999999 .54
      15033    1 .689999999999999 .55
      15034 1.01 .699999999999999 .56
      15035 1.02 .709999999999999 .57
      15036 1.03 .719999999999999 .58
      15037 1.04 .729999999999999 .59
      15038 1.05 .739999999999999  .6
      15039 1.06 .749999999999999 .61
      15040 1.07 .759999999999999 .62
      15041 1.08 .769999999999999 .63
      15042 1.09 .779999999999999 .64
      15043  1.1 .789999999999999 .65
      15044 1.11 .799999999999999 .66
      15045 1.12 .809999999999999 .67
      15046 1.13 .819999999999999 .68
      15047 1.14 .829999999999999 .69
      15048 1.15 .839999999999999  .7
      15049 1.16 .849999999999999 .71
      15050 1.17 .859999999999999 .72
      15051 1.18 .869999999999999 .73
      15052 1.19 .879999999999999 .74
      15053  1.2 .889999999999999 .75
      15054 1.21 .899999999999999 .76
      15055 1.22 .909999999999999 .77
      15056 1.23 .919999999999999 .78
      15057 1.24 .929999999999999 .79
      15058 1.25 .939999999999999  .8
      15059 1.26 .949999999999999 .81
      15060 1.27 .959999999999999 .82
      15061 1.28 .969999999999999 .83
      15062 1.29 .979999999999999 .84
      15063  1.3 .989999999999999 .85
      15064 1.31 .999999999999999 .86
      15065 1.32             1.01 .87
      15066 1.33             1.02 .88
      15067 1.34             1.03 .89
      15068 1.35             1.04  .9
      15069 1.36             1.05 .91
      15070 1.37             1.06 .92
      15071 1.38             1.07 .93
      15072 1.39             1.08 .94
      15073  1.4             1.09 .95
      15074 1.41              1.1 .96
      15075 1.42             1.11 .97
      end
      format %tdnn/dd/CCYY Time

      Comment


      • #4
        Code:
        reshape long Ind, i(Time) j(Company) string
        encode Company, g(id)
        xtset id Time

        Comment


        • #5
          Thank you so much Andrew!

          Comment

          Working...
          X