你之前的变量应该是文字变量吧,先转化为数值变量
destring date , replace ignore("-,")
年月日分离:
gen year = substr(date, 1, 4)
gen month = substr(date, 5, 2)
gen day = substr(date, 7, 2)
然后把月份转化为单词,运用if replace 语句把数字转华为文字:tostring year month day, replace
然后把日期重新组合
gen date1 = day + month + year
你试试看啊