Hello ,
I'm working on computing age of firms from incorporation date. Some of the dates in my data are listed in dd/mm/yyyy format while others in yyyy format. I used the following commands to generate two variables date and date1 and age1 and age2 :
Please see below the sample data:
I want to generate a single column for age by merging age1 and age2 variables. Could someone please help with the code or guide me as to a better way to do this.
Thank you.
I'm working on computing age of firms from incorporation date. Some of the dates in my data are listed in dd/mm/yyyy format while others in yyyy format. I used the following commands to generate two variables date and date1 and age1 and age2 :
Code:
gen int date = daily( INCORPORATION_DATE , "DMY", 2019 gen int date1 = daily( INCORPORATION_DATE , "Y", 2019) gen age1= (td(1jan2020) - date1 )/365.25 gen age2 = (td(1jan2020) - date)/365.25
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str10 INCORPORATION_DATE int(date date1) float(age1 age2) "29/12/1992" 12051 . . 27.00616 "27/09/1969" 3557 . . 50.26146 "30/06/1992" 11869 . . 27.50445 "11/06/2007" 17328 . . 12.55852 "07/05/1962" 857 . . 57.65366 "03/09/1985" 9377 . . 34.32717 "09/10/2008" 17814 . . 11.227926 "24/04/1989" 10706 . . 30.68857 "26/09/2000" 14879 . . 19.26352 "23/04/1993" 12166 . . 26.691307 "02/04/2004" 16163 . . 15.748117 "19/11/2007" 17489 . . 12.117727 "21/11/1985" 9456 . . 34.11088 "19/09/2000" 14872 . . 19.28268 "21/06/2006" 16973 . . 13.530458 "20/12/2006" 17155 . . 13.03217 "29/06/2007" 17346 . . 12.50924 "10/12/2010" 18606 . . 9.059548 "18/07/2001" 15174 . . 18.455853 "17/09/2008" 17792 . . 11.288158 "22/02/2010" 18315 . . 9.856263 "01/11/2005" 16741 . . 14.16564 "26/09/2002" 15609 . . 17.264887 "22/07/2002" 15543 . . 17.445585 "27/07/1993" 12261 . . 26.43121 "08/09/1925" -12533 . . 94.31348 "1902" . -21184 117.99863 . "04/03/2003" 15768 . . 16.829569 "05/10/2002" 15618 . . 17.240246 "21/05/2007" 17307 . . 12.616016 end
I want to generate a single column for age by merging age1 and age2 variables. Could someone please help with the code or guide me as to a better way to do this.
Thank you.
Comment