Question

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.

Was it helpful?

Solution

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top