Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72764

Date Translation from type: double, format: %tcnn/dd/ccYY to %tdDMy

$
0
0
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
Code:
regdate = 6/12/1961 00:00:00
surveydate = 2008-12-31 00:00:00.00
Using
Code:
gen sur_date = date(surveydate , "YMDhms")
format %tdDMY sur_date
I managed to convert surveydate as of:

Code:
 sur_date 31December08
I can't do the same to the regdate variable. After using
Code:
gen birthday = regdate
format %tdDMY birthday
I get
Code:
birthday  = 4.56192e+10
I then calculate the firm age by
Code:
gen age = (surveydate- birthday)/365.25
that gives
Code:
age = -1.25e+08
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.

Viewing all articles
Browse latest Browse all 72764

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>