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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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