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.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 4787 views
  • 0 likes
  • 3 in conversation