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