BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
timmy94
Calcite | Level 5

I am trying to convert a date currently in character form to correct format, but my code is changing the date. Could anyone please point out what I am doing wrong?

 

mthyr_birth (existing data)

Jun2001

Feb1954

Feb1984

 

My code:

data want;

set have;

mthyr_birth2 = input(mthyr_birth, MONYY.);

format mthyr_birth2 MONYY.;

run;

 

mthyr_birth2 (output)

JUN20

FEB19

FEB19

 

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

By default, the MONYY uses a width of 5.  So the INPUT function is reading only 5 characters.  Your data has 7 characters in it, so change MONYY to MONYY7 and you should see better results.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

By default, the MONYY uses a width of 5.  So the INPUT function is reading only 5 characters.  Your data has 7 characters in it, so change MONYY to MONYY7 and you should see better results.

timmy94
Calcite | Level 5
Thanks so much! 🙂

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 340 views
  • 1 like
  • 2 in conversation