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

Hi,

 

This is a really simple problem, but I can't seem to find a solution.

 

My date variable is in an informat and format of DATETIME20. I want it to be in a MMDDYY10. format. How do I change my date variable from a DATETIME20. to MMDDYY10. format? I want my date variable that looks like this "01FEB2016:00:00:00" to look like this "02/01/2016."

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

You want the datepart() function:

data want;
  thedt="01FEB2016:00:00:00"dt;
  thedt=datepart(thedt);
  format thedt mmddyy10.;
run;

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

You want the datepart() function:

data want;
  thedt="01FEB2016:00:00:00"dt;
  thedt=datepart(thedt);
  format thedt mmddyy10.;
run;
amanda_cr
Calcite | Level 5

Awesome. That works perfectly!

 

Thank you, RW9.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 16347 views
  • 0 likes
  • 2 in conversation