SAS关于身份证号码的提取分析
-
data ex; input ID $1-20 year 7-10 mon 11-12 day 13-14; cards; 110103197512092232 110101196902150059 ; run; /*如果身份证前空格,错误原因?*/ data ex; input id $1-50 year 7-10 mon 11-12 day 13-14; year=substr(id,7,4); month=substr(id,11,2); day=substr(id,13,2); birthday=mdy(month,day,year); birthday1=put(mdy(month,day,year),WORDDATE.); age=year(today())-year(birthday); cards; 110103197512092232 110101196902150059 ; run; proc print data=ex; run; DATA EX2; SET EX; YEAR=SUBSTR(LEFT(RIGHT(ID)),7,4); RUN;