Hello, I want to calculate the age of firms at the time of survey whose registration date and the survey date are reported in different types and formats.
The registration dates are reported as double and %tcnn/dd/ccYY, while the survey date are as str23 and %23s
Using
I managed to convert surveydate as of:
I can't do the same to the regdate variable. After using
I get
I then calculate the firm age by
that gives
which seems not right at all.
I am not sure if the way I did with my regdate variable is valid (as it is in double type). Any suggestion for a better way to calculate the age of the firm would be really appreciated.
Thank you very much in advance.
The registration dates are reported as double and %tcnn/dd/ccYY, while the survey date are as str23 and %23s
Code:
regdate = 6/12/1961 00:00:00 surveydate = 2008-12-31 00:00:00.00
Code:
gen sur_date = date(surveydate , "YMDhms") format %tdDMY sur_date
Code:
sur_date 31December08
Code:
gen birthday = regdate format %tdDMY birthday
Code:
birthday = 4.56192e+10
Code:
gen age = (surveydate- birthday)/365.25
Code:
age = -1.25e+08
I am not sure if the way I did with my regdate variable is valid (as it is in double type). Any suggestion for a better way to calculate the age of the firm would be really appreciated.
Thank you very much in advance.