BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Kody_devl
Quartz | Level 8

I have a dataset with a character date field (Source_Date Char(35)) with data in this format, "mmddyy" (no slashes) .  I want to:

 

1.  Add a new date field,  "Source_Date_dte mmddyy8."

2.  Update the new Source_Date_dte field with the date value from the Source_Date.

 

For Example:               New field value

060116-------------------> 06/01/16

 

Here is my code attempt:

data ALL_MONTHS_LOAN_DETAIL_new;

set ALL_MONTHS_LOAN_DETAIL;

Source_Date_dte=input(Source_Date, 6.);

format Source_Date_dte mmddyy8.;

run:

 

This code produces a new field Source_Date_dte Character 15 with format $MDDYY10 and no data populated in the new field.

 

Help Please

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
3 REPLIES 3
Reeza
Super User

Use the appropriate date informat. In your input function try mmddyy6. as the informat rather than 6. 

Astounding
PROC Star

Your statement would always create a numeric variable (even if you need to adjust it according to Reeza's suggestion, the same applies).  If you are getting a character variable as the result, it is because SOURCE_DATE_DTE already exists (as a character variable) within the incoming data set ALL_MONTH_LOANS_DETAIL.  It should be dropped from the input.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 3777 views
  • 0 likes
  • 3 in conversation