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

I've been fighting with this one and it's time to just ask for help. 

I tried other solutions from the community forums but they didn't work

 

So let's call the variable RPT_DATE.  The data I received is formatted like: 3/11/2020 9:01:54 AM

When I import this it appears as 11MAR20:09:01:54  Format as DATETIME. Informat ANYDTDTM40.

 

What I need to do is convert this so that it reads as 03/11/2020.

 

I'm sorry, I am sure this is simple but I have struck out at this point.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Use the DATEPART function. In a DATA step:

 

date_only=datepart(rpt_date);
format date_only mmddyy.;

 

 

What I need to do is convert this so that it reads as 03/11/2020.

 

Adding, this is often a poor choice to format dates, as the above date can be interpreted as March 11 or November 3. So I recommend you avoid using this format if at all possible.

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

Use the DATEPART function. In a DATA step:

 

date_only=datepart(rpt_date);
format date_only mmddyy.;

 

 

What I need to do is convert this so that it reads as 03/11/2020.

 

Adding, this is often a poor choice to format dates, as the above date can be interpreted as March 11 or November 3. So I recommend you avoid using this format if at all possible.

--
Paige Miller

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 Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 390 views
  • 0 likes
  • 2 in conversation