Announcement

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

  • Ferquency table for panel data

    Hello dear all,
    I have panel data from 26 countries from 1995-2020. I want to get the frequency of the 3 variables ( different policies) --eg percent of the time is market, the percent is not market, and percent using technology.
    also, each of them also have three sub-components.
    when I used the : I try to get these table once onlcy based on the main component and then main component with the sub-component.

    Code:
     table mkt , statistic(frequency) statistic(percent)
    
    ------------------------------
            |  Frequency   Percent
    --------+---------------------
    mkt     |                     
      0     |        208      2.18
      .17   |        292      3.06
      .33   |        219      2.29
      .5    |        579      6.06
      .67   |      1,158     12.12
      .83   |      1,891     19.80
      1     |      1,662     17.40
      1.17  |      1,024     10.72
      1.33  |        446      4.67
      1.5   |        364      3.81
      1.67  |        250      2.62
      1.83  |        183      1.92
      2     |        229      2.40
      2.17  |        226      2.37
      2.33  |        115      1.20
      2.5   |        151      1.58
      2.67  |         88      0.92
      2.83  |         69      0.72
      3     |         63      0.66
      3.17  |         60      0.63
      3.33  |         33      0.35
      3.5   |         33      0.35
      3.67  |         60      0.63
      3.83  |         47      0.49
      4     |         48      0.50
      4.17  |         54      0.57
      Total |      9,552    100.00
    ------------------------------
    and
    Code:
    . table nmkt , statistic(frequency) statistic(percent)
    
    ------------------------------
            |  Frequency   Percent
    --------+---------------------
    nmkt    |                     
      0     |        112      1.17
      .25   |        325      3.40
      1     |        297      3.11
      1.25  |         50      0.52
      1.5   |      1,264     13.23
      1.75  |        437      4.57
      2     |        462      4.84
      2.25  |         61      0.64
      2.5   |        985     10.31
      2.75  |         73      0.76
      3     |        496      5.19
      3.25  |         34      0.36
      3.5   |        120      1.26
      4     |        143      1.50
      4.25  |        375      3.93
      4.5   |        153      1.60
      4.75  |        790      8.27
      5     |        633      6.63
      5.25  |        404      4.23
      5.5   |      1,838     19.24
      5.75  |        353      3.70
      6     |        147      1.54
      Total |      9,552    100.00
    ------------------------------
    
    .
    Code:
    . table mkt co2_tax_mr nox_tax_mr sox_tax_mr , statistic(frequency) statistic(percent)
    
    ---------------------------------------------------------------------------------
                          |                         sox_tax_mr                       
                          |      0      1      2      3      4      5      6    Total
    ----------------------+----------------------------------------------------------
    mkt                   |                                                          
      0                   |                                                          
        co2_tax_mr        |                                                          
          0               |                                                          
            nox_tax_mr    |                                                          
              0           |                                                          
                Frequency |    208                                                208
                Percent   |   2.18                                               2.18
              Total       |                                                          
                Frequency |    208                                                208
                Percent   |   2.18                                               2.18
          Total           |                                                          
            nox_tax_mr    |                                                          
              0           |                                                          
                Frequency |    208                                                208
                Percent   |   2.18                                               2.18
              Total       |                                                          
                Frequency |    208                                                208
                Percent   |   2.18                                               2.18
      .17                 |                                                          
        co2_tax_mr        |                                                          
          0               |                                                          
            nox_tax_mr    |                                                          
              0           |                                                          
                Frequency |    292                                                292
                Percent   |   3.06                                               3.06
              Total       |                                                          
                Frequency |    292                                                292
                Percent   |   3.06                                               3.06
          Total           |                                                          
            nox_tax_mr    |                                                          
              0           |                                                          
                Frequency |    292                                                292
                Percent   |   3.06                                               3.06
              Total       |                                                          
                Frequency |    292                                                292
                Percent   |   3.06                                               3.06
      .33                 |                                                          
        co2_tax_mr        |                                                          
          0               |                                                          
            nox_tax_mr    |                                                          
              0           |                                                          
                Frequency |    219                                                219
                Percent   |   2.29                                               2.29
              Total       |                                                          
                Frequency |    219                                                219
                Percent   |   2.29                                               2.29
          Total           |                                                          
            nox_tax_mr    |                                                          
              0           |
    the table is so confusing.
    I appreciate receiving your comments how can I get this table in panel data?


    Many thanks in advance.
    Best regards,

  • #2
    The -table- command is complicated enough that it would be very difficult to write the correct code without having example data to work with. More generally, it is usually a bad idea to ask for code help without showing example data. So use the -dataex- command and post back with that. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    In addition, I don't understand exactly what the results table you would like to get looks like. Could you mock up a brief illustration of what you want to see and post back with that?

    Comment


    • #3
      @Clyde Schechter thanks a lot for your reply and sorry for the limited information that I shared.
      this is a part of my data:
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str4 Country float year double mkt float(sum_tax_mr sum_cert_mr) double(nmkt tec) float(sum_adoption_tec rdexp_tec)
      "AUT" 1980    .        .         .    .    .    .   .
      "AUT" 1981    .        .         .    .    .    .   .
      "AUT" 1982    .        .         .    .    .    .   .
      "AUT" 1983    .        .         .    .    .    .   .
      "AUT" 1984    .        .         .    .    .    .   .
      "AUT" 1985    .        .         .    .    .    .   .
      "AUT" 1986    .        .         .    .    .    .   .
      "AUT" 1987    .        .         .    .    .    .   .
      "AUT" 1988    .        .         .    .    .    .   .
      "AUT" 1989    .        .         .    .    .    .   .
      "AUT" 1990  .67 .6666667         0    3   .5    0  .5
      "AUT" 1991  .67 .6666667         0    3   .5    0  .5
      "AUT" 1992  .67 .6666667         0    3   .5    0  .5
      "AUT" 1993  .67 .6666667         0    3   .5    0  .5
      "AUT" 1994  .67 .6666667         0    3   .5    0  .5
      "AUT" 1995  .83 .8333333         0    3    1   .5  .5
      "AUT" 1996  .83 .8333333         0    3    1   .5  .5
      "AUT" 1997  .83 .8333333         0    3    1   .5  .5
      "AUT" 1998  .83 .8333333         0    3    1   .5  .5
      "AUT" 1999  .83 .8333333         0    3    1   .5  .5
      "AUT" 2000  .67 .6666667         0    4    1   .5  .5
      "AUT" 2001  .67 .6666667         0    4    1   .5  .5
      "AUT" 2002  .67 .6666667         0    4    1   .5  .5
      "AUT" 2003  .83 .8333333         0    4 1.75 1.25  .5
      
      
      end
      ------------------ copy up to and including the previous line ------------------

      here
      sum_cert_mr
      and
      sum_tax_mr
      are sub component of the
      mkt
      . and
      sum_adoption_tec
      and
      rdexp_tec
      are sub-component of the
      tec
      .

      I want to get the percent of the time of the
      mkt
      nmkt
      and
      tec
      in the frequency table. then
      mkt
      and its sub-component.

      Many thanks in advance for your valuable time and advice.



      Best regards,

      Comment


      • #4
        Thank you for the example data. But I still do not understand what kind of table you want. Please, using just the same data you showed in your -datatex- example, draw up (by hand) a table that looks like what you want and post it here. Then I will try to find commands that will produce that (or come as close as I can). Right now, I really don't understand what you're looking for.

        Comment


        • #5
          @Clyde Schechter many thanks for your reply and your valuable time. I want a table like this for my variable in the dataset ( actually, I want to see the percentage of the time on my variables in the year). but as it is panel data I am confused. Many thanks in advance.
          Code:
           
          mkt tec
          Freq. Percent Cum. total Percent Cum. Freq. total
          1980
          1981
          1982
          1983
          1984
          1985
          1986
          1987
          1988
          1989
          1990
          1991
          1992
          1993
          1994
          1995
          1996
          1997
          1998
          1999
          2000
          2001
          2002
          Best regards,

          Comment


          • #6
            I'm sorry, but I still don't understand. The table shell you have shown does not seem to be relatable to the data you have. Probably I'm missing something. What would help is if you fill in the table shell in #5 with the actual numbers you want to see in the cells of that table using the data shown in the -dataex- output of #3.

            Comment


            • #7
              @Clyde Schechter many thanks for your reply and really sorry I take your time. because my data is panel data, want the sum of the frequency of my variable in each year ( i.e., I want to see the percentage time frequency of the "mkt" in the whole sample in 1995, 1996 ,...). not for every country separately.

              I hope I could explain.


              Many thanks in advance.

              Best regards,

              Comment


              • #8
                I don't know what you mean by "the percentage time frequency of the "mkt" in the whole sample." I think that explaining in words will not be helpful. Please use the small example of your data in #3 and use a hand calculator or spreadsheet to calculate the actual numbers you would want to see and put them in the appropriate places in the table shell you showed in #5.

                Comment

                Working...
                X