Announcement

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

  • Missing all variables

    Hi all,

    I do have a particular question. I organized one particular dataset in 5 year averages in order to be able to do a merge (the other dataset is in five year intervals), following this command:

    Code:
      gen period=5*floor(year/5)
    Code:
     gen ly=log(val_per_worker)
    Code:
     collapse val_per_worker ly wages_per_person lwages, by(country1 isic period)


    Then, I grouped my variables into country_industry to be able to build a panel

    Code:
     egen country_industry= group (country isic)
    Code:
     xtset country_industry period
    Later, I wanted to calculate growth rates on 5 year intervals. Since the data is already in five years, I did the following command:

    Code:
     gly= (ly-L1.ly)
    And then I get that gly is missing for all observations. Any possible hint? Thank you very much!

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int country1 str2 isic float(period val_per_worker ly lwages wages_per_person)
    4 "15" 1970 . .        .         .
    4 "15" 1975 . .        .         .
    4 "15" 1980 . .        .         .
    4 "15" 1985 . .        .         .
    4 "15" 1990 . .        .         .
    4 "15" 2000 . . 6.890805  983.8124
    4 "15" 2005 . . 7.024784 1128.1134
    4 "15" 2010 . . 7.236641  1390.738
    4 "15" 2015 . .        .         .
    4 "16" 1970 . .        .         .
    4 "16" 1975 . .        .         .
    4 "16" 1980 . .        .         .
    4 "16" 1985 . .        .         .
    4 "16" 1990 . .        .         .
    4 "16" 2000 . .        .         .
    4 "16" 2005 . .        .         .
    4 "16" 2010 . .        .         .
    4 "16" 2015 . .        .         .
    4 "17" 1970 . .        .         .
    4 "17" 1975 . .        .         .
    4 "17" 1980 . .        .         .
    4 "17" 1985 . .        .         .
    4 "17" 1990 . .        .         .
    4 "17" 2000 . . 6.959348 1054.3126
    4 "17" 2005 . . 7.041875 1147.0007
    4 "17" 2010 . . 7.236204 1390.1355
    4 "17" 2015 . .        .         .
    4 "18" 1970 . .        .         .
    4 "18" 1975 . .        .         .
    4 "18" 1980 . .        .         .
    4 "18" 1985 . .        .         .
    4 "18" 2000 . .        .         .
    4 "18" 2005 . .        .         .
    4 "18" 2010 . .        .         .
    4 "18" 2015 . .        .         .
    4 "19" 1970 . .        .         .
    4 "19" 1975 . .        .         .
    4 "19" 1980 . .        .         .
    4 "19" 1985 . .        .         .
    4 "19" 2000 . .        .         .
    4 "19" 2005 . .        .         .
    4 "19" 2010 . .        .         .
    4 "19" 2015 . .        .         .
    4 "20" 1970 . .        .         .
    4 "20" 1975 . .        .         .
    4 "20" 1980 . .        .         .
    4 "20" 1985 . .        .         .
    4 "20" 1990 . .        .         .
    4 "20" 2000 . .  6.89531   988.408
    4 "20" 2005 . . 7.024716 1131.3408
    4 "20" 2010 . . 7.236292 1390.2756
    4 "20" 2015 . .        .         .
    4 "21" 1970 . .        .         .
    4 "21" 1975 . .        .         .
    4 "21" 1980 . .        .         .
    4 "21" 1985 . .        .         .
    4 "21" 1990 . .        .         .
    4 "21" 2000 . .        .         .
    4 "21" 2005 . .        .         .
    4 "21" 2010 . .        .         .
    4 "21" 2015 . .        .         .
    4 "22" 1970 . .        .         .
    4 "22" 1975 . .        .         .
    4 "22" 1980 . .        .         .
    4 "22" 1985 . .        .         .
    4 "22" 1990 . .        .         .
    4 "22" 2000 . . 6.867974  982.9714
    4 "22" 2005 . . 7.066131 1174.0973
    4 "22" 2010 . . 7.236682 1390.7927
    4 "22" 2015 . .        .         .
    4 "23" 1970 . .        .         .
    4 "23" 1975 . .        .         .
    4 "23" 1980 . .        .         .
    4 "23" 1985 . .        .         .
    4 "23" 1990 . .        .         .
    4 "23" 2000 . .        .         .
    4 "23" 2005 . .        .         .
    4 "23" 2010 . .        .         .
    4 "23" 2015 . .        .         .
    4 "24" 1970 . .        .         .
    4 "24" 1975 . .        .         .
    4 "24" 1980 . .        .         .
    4 "24" 1985 . .        .         .
    4 "24" 1990 . .        .         .
    4 "24" 2000 . . 6.860497  954.5614
    4 "24" 2005 . . 7.006566 1113.6434
    4 "24" 2010 . . 7.236639  1390.731
    4 "24" 2015 . .        .         .
    4 "25" 1970 . .        .         .
    4 "25" 1975 . .        .         .
    4 "25" 1980 . .        .         .
    4 "25" 1985 . .        .         .
    4 "25" 1990 . .        .         .
    4 "25" 2000 . . 6.985865 1095.2495
    4 "25" 2005 . .  7.02529 1128.6703
    4 "25" 2010 . . 7.236648  1390.751
    4 "25" 2015 . .        .         .
    4 "26" 1970 . .        .         .
    4 "26" 1975 . .        .         .
    4 "26" 1980 . .        .         .
    end
    Last edited by Hugo Rocha; 03 Jun 2022, 11:35.

  • #2
    The problem is that your -xtset- command is not consistent with the data. With no -delta()- option specified, -xtset- causes Stata to assume that the interval between consecutive observations is 1 time unit. Consequently, when you use L1.ly, Stata thinks you mean the value of ly from one year earlier. But in your data, the difference is 5 time units. So you need
    Code:
    xtset country_industry period, delta(5)
    That way, Stata will expect the data to be at 5 year intervals, and L1.ly will be understood to mean the observation five years earlier.

    The other reason you are getting all observations, however, is that, at least in your example, ly itself, and val_per_worker (from which ly is calculated), are always missing value!

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      The problem is that your -xtset- command is not consistent with the data. With no -delta()- option specified, -xtset- causes Stata to assume that the interval between consecutive observations is 1 time unit. Consequently, when you use L1.ly, Stata thinks you mean the value of ly from one year earlier. But in your data, the difference is 5 time units. So you need
      Code:
      xtset country_industry period, delta(5)
      That way, Stata will expect the data to be at 5 year intervals, and L1.ly will be understood to mean the observation five years earlier.

      The other reason you are getting all observations, however, is that, at least in your example, ly itself, and val_per_worker (from which ly is calculated), are always missing value!
      Thank you very much! (the delta seems to be the problem).Ly is not always missing. In fact, the summary statistics for ly is:

      Code:
        gen ly=log(val_per_worker)
      Code:
       sum ly
      
          Variable |        Obs        Mean    Std. Dev.       Min        Max
      -------------+---------------------------------------------------------
                ly |     15,727    9.396028    1.380551   3.150056   20.38817
      (I do not know why dataex shows it as missing)

      Comment


      • #4
        Well, unless you tell -dataex- otherwise by using -if- or -in- conditions or the -count()- option, it always produces data from the first 100 observations in the data set. I suppose, for some reason, it happens to be missing in the first 100 observations. Try -summ ly in 1/100- to verify this.

        Comment


        • #5
          Originally posted by Clyde Schechter View Post
          Well, unless you tell -dataex- otherwise by using -if- or -in- conditions or the -count()- option, it always produces data from the first 100 observations in the data set. I suppose, for some reason, it happens to be missing in the first 100 observations. Try -summ ly in 1/100- to verify this.
          That's correct. Thank you so much!

          Code:
           summ ly in 1/100 (If I do it for the first 200 hundred, 300 hundred, I start getting summary statistics...)
          
              Variable |        Obs        Mean    Std. Dev.       Min        Max
          -------------+---------------------------------------------------------
                    ly |          0
          Last edited by Hugo Rocha; 03 Jun 2022, 11:59.

          Comment

          Working...
          X