Announcement

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

  • firm age

    Hello,

    I have 26,000 observations. I would like to calculate the age of these incorporations. What should I do? I am quite new to all this. The "Date of incorporation" is listed as a string value and looks like this;

    31/12/1997
    31/12/2000
    31/12/2004
    31/12/2012

    Thank you.

  • #2
    help datetime will get you started; for example:
    Code:
    gen int newdate = daily(oldvar,"DMY")
    format newdate %td
    you don't say when you want the age calculated to but you can then just subtract the newdate from the "goal" date; e.g.,
    Code:
    gen age=td(31dec2018) - newdate
    which will give you age in days

    my "newdate" and "oldvar" should, of course, be changed to whatever you want (or is already in your data)

    Comment


    • #3
      Thank you Rich! Worked great!

      Comment


      • #4
        I have a quick question, would you generate an age that is not static? As in, I need my date to be changing. My sample is from 2012-2016 and so the age has to change every year not for just December 31 2018 - Age variable. Thank you for your help it is much much appreciated.

        Comment


        • #5
          Yours Age is for years 2012 -2016
          the mean of Age for years
          clear
          input int Y2012 Y2013 Y2014 Y2015 Y2016
          1 2 3 4 5
          2 3 4 5 6
          3 5 6 6 7
          end
          local Y "Y2012 Y2013 Y2014 Y2015 Y2016"
          foreach x of local Y{
          egen Mean`x'=mean(`x')
          }

          Comment


          • #6
            You might try this (note that if they really were founded on 31-DEC-1997, you might want year_founded = 1998 instead of 1997.

            Code:
            dataex firm_id year date_founded_str  //  To install: ssc install dataex
            clear
            input byte firm_id int year str10 date_founded_str
            1 2012 "31/12/1997"
            1 2013 "31/12/1997"
            1 2014 "31/12/1997"
            1 2015 "31/12/1997"
            1 2016 "31/12/1997"
            2 2012 "31/12/2000"
            2 2013 "31/12/2000"
            2 2014 "31/12/2000"
            2 2015 "31/12/2000"
            2 2016 "31/12/2000"
            3 2012 "31/12/2004"
            3 2013 "31/12/2004"
            3 2014 "31/12/2004"
            3 2015 "31/12/2004"
            3 2016 "31/12/2004"
            4 2013 "31/12/2012"
            4 2014 "31/12/2012"
            4 2015 "31/12/2012"
            4 2016 "31/12/2012"
            end
            ------------------ copy up to and including the previous line ------------------

            Code:
            gen double date_founded = daily(date_founded_str, "DMY")
            format date_founded %td
            gen year_founded = year( date_founded)
            gen firm_age = year - year_founded
            
            . list, sepby(firm_id) abbrev(15) noobs
            
              +---------------------------------------------------------------------------+
              | firm_id   year   date_founded_~r   date_founded   year_founded   firm_age |
              |---------------------------------------------------------------------------|
              |       1   2012        31/12/1997      31dec1997           1997         15 |
              |       1   2013        31/12/1997      31dec1997           1997         16 |
              |       1   2014        31/12/1997      31dec1997           1997         17 |
              |       1   2015        31/12/1997      31dec1997           1997         18 |
              |       1   2016        31/12/1997      31dec1997           1997         19 |
              |---------------------------------------------------------------------------|
              |       2   2012        31/12/2000      31dec2000           2000         12 |
              |       2   2013        31/12/2000      31dec2000           2000         13 |
              |       2   2014        31/12/2000      31dec2000           2000         14 |
              |       2   2015        31/12/2000      31dec2000           2000         15 |
              |       2   2016        31/12/2000      31dec2000           2000         16 |
              |---------------------------------------------------------------------------|
              |       3   2012        31/12/2004      31dec2004           2004          8 |
              |       3   2013        31/12/2004      31dec2004           2004          9 |
              |       3   2014        31/12/2004      31dec2004           2004         10 |
              |       3   2015        31/12/2004      31dec2004           2004         11 |
              |       3   2016        31/12/2004      31dec2004           2004         12 |
              |---------------------------------------------------------------------------|
              |       4   2013        31/12/2012      31dec2012           2012          1 |
              |       4   2014        31/12/2012      31dec2012           2012          2 |
              |       4   2015        31/12/2012      31dec2012           2012          3 |
              |       4   2016        31/12/2012      31dec2012           2012          4 |
              +---------------------------------------------------------------------------+

            Comment


            • #7
              And how do you get the age in years, based on the year of incorporation of the firm?

              Comment


              • #8
                Age in 2021 = 2021 - year of incorporation.

                Comment


                • #9
                  Thanks! but is there a command for this? Sorry, I am new to Stata.

                  Comment


                  • #10
                    Code:
                    help generate

                    Comment


                    • #11
                      Thank you!

                      Comment

                      Working...
                      X