Hello,

I was trying to make the date variable below into a yearly variable. I did the following: gen date2 = date(date, "Y")
However it only showed missing values. Is this because the value is a string value? How would I go about it to get a yearly value for each value?

Thanks!


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str10 date float(pieati01dea661n date2)
"2007-01-01"  93.03768 .
"2008-01-01"  96.93327 .
"2009-01-01"  93.65627 .
"2010-01-01"   95.4023 .
"2011-01-01"   99.3774 .
"2012-01-01" 101.11848 .
"2013-01-01" 100.90383 .
"2014-01-01" 100.29961 .
"2015-01-01"       100 .
"2016-01-01"  99.16666 .
"2017-01-01" 101.14167 .
end