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

Hi,

I have a two different date formats:

       07SEP03:00:00:00

2009-08-06 00:00:00.000

 

I want to change it to:

09/07/2020

08/06/2009

 

can I do it in sas?

thanks in advance.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Try this:

data want;
set have;
x = input(variable, anydtdtm.);
y = datepart(x);
format y mmddyy10.;
run;

View solution in original post

2 REPLIES 2
ballardw
Super User

Neither of those is a date. Those are DATETIME values.

If they are an actual SAS datetime, meaning numeric with a datetime format of some sort attached then it would be easy to either extract the date part of the value using the DATEPART function and assign the MMDDYY format.

 

But you need to provide data step code of what you actually have.

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

Reeza
Super User
Try this:

data want;
set have;
x = input(variable, anydtdtm.);
y = datepart(x);
format y mmddyy10.;
run;

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

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1030 views
  • 0 likes
  • 3 in conversation