Hi, I have looked through older discussions and applied suggestions but my code returns an empty variable when i try to gen a year variable from my date variable. Please help. I just really want to keep the year from the date. And i want the year to be in the 4-number format. For example, 15 should become 2015. DATEINTR is the original variable. I clonevarred "date" to generate and also inform stata it is a date variable.

----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(date DATEINTR)
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
 1.748736e+12  1.748736e+12
1.7488224e+12 1.7488224e+12
1.7488224e+12 1.7488224e+12
1.7488224e+12 1.7488224e+12
1.7488224e+12 1.7488224e+12
1.7488224e+12 1.7488224e+12
1.7488224e+12 1.7488224e+12
1.7488224e+12 1.7488224e+12
1.7496864e+12 1.7496864e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7486496e+12 1.7486496e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
1.7489088e+12 1.7489088e+12
   1.7496e+12    1.7496e+12
   1.7496e+12    1.7496e+12
   1.7496e+12    1.7496e+12
   1.7496e+12    1.7496e+12
   1.7496e+12    1.7496e+12
   1.7496e+12    1.7496e+12
   1.7496e+12    1.7496e+12
   1.7496e+12    1.7496e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7497728e+12 1.7497728e+12
1.7497728e+12 1.7497728e+12
1.7497728e+12 1.7497728e+12
1.7497728e+12 1.7497728e+12
1.7497728e+12 1.7497728e+12
1.7497728e+12 1.7497728e+12
1.7497728e+12 1.7497728e+12
1.7497728e+12 1.7497728e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7496864e+12 1.7496864e+12
1.7499456e+12 1.7499456e+12
1.7499456e+12 1.7499456e+12
1.7499456e+12 1.7499456e+12
1.7499456e+12 1.7499456e+12
1.7499456e+12 1.7499456e+12
1.7499456e+12 1.7499456e+12
1.7499456e+12 1.7499456e+12
1.7499456e+12 1.7499456e+12
1.7498592e+12 1.7498592e+12
1.7498592e+12 1.7498592e+12
1.7498592e+12 1.7498592e+12
1.7498592e+12 1.7498592e+12
end
format %tcDD.NN.YY date
format %tcDD.NN.YY DATEINTR
------------------ copy up to and including the previous line ------------------

Listed 100 out of 53935 observations
Use the count() option to list more

. gen year=year(date)
(53,935 missing values generated)