Announcement

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

  • Calculate company age if the date of incorporation is given

    Hello!

    I need to calculate the company's age, where the incorporation date is given. However, the information is not in the same format for every observation, and the variable type is str10.
    Namely, some observations have DD/MM/YY format, some MM/YY, and others only YY given. How should I approach this problem? Ideally, I would only need the Year of incorporation of each company, if that makes sense.

    I would really appreciate any help, for I am struggling with this for a while now.

    Thank you in advance!

  • #2
    Guest:
    I would stop struggling myself at the the year of incorporation and leave months and days to their own devices.
    Last edited by sladmin; 04 Aug 2017, 14:45. Reason: anonymize poster
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Carlo, Thank you for your reply!

      I am afraid I do not quite understand you. If I do so, given the different formats, what would be the way to still compute the company's age given the information ? Because my main concern is computing its age. Or maybe I should provide some more information to be clearer?

      Best,
      Guest
      Last edited by sladmin; 04 Aug 2017, 14:45. Reason: anonymize poster

      Comment


      • #4
        Guest:
        i meant that you have to extract year from dates reported in DD/MM/YY and MM/YY formats.
        See -help datetime- and related entries in Stata .pdf manual.
        Sorry I cannot delve into this issue at the present moment.
        Last edited by sladmin; 04 Aug 2017, 14:45. Reason: anonymize poster
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Although you're saying that you have DD/MM/YY I will guess that your data look like

          Code:
          "1979"
          "07/2005"
          "12/12/2013"
          If so, something like

          Code:
          gen year = real(substr(incorp, -4, 4))
          should help. If that doesn't make sense or doesn't work, then please back up and give us a real(istic) data example as requested in FAQ Advice #12.

          Comment


          • #6
            Dear Nick,
            Yes, exactly, that is how the data looks like. I apologize, my bad!

            Perfect! Thank you very much for your help!

            Comment

            Working...
            X