문제

I have the following :

data a_test;
input date $;
cards;
2013M10
2013M11
2013M12
2014M1
;
run; 

The dates are in a text format , not dates.

How would you do to change them in a date format like Dec 2013?

I was thinking of removing the M and put instead a / or just leave as a space.

Any insights would be welcome.

도움이 되었습니까?

해결책

Use the MDY function to convert the text to dates.

data a_test;
input date $;
new_date=mdy(substr(date,6,2),01,substr(date,1,4));
format new_date monyy5.;
cards;
2013M10
2013M11
2013M12
2014M1
;
run;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top