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;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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