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

Hi All,

 

I have a date variable which I want to display like this YYYYMMDD:HH:MM. I don't want to display the seconds value. I am not able to find any date time format which will help me in the above scenario.

Can anyone tell me how to do this. Do we have any format available to do this?

id       date

101    2021-01-21:15:25

102    2021-02-15:08:30

...

 

Shantanu

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

e8601dt16.

 

Or, create your own custom format using the PICTURE statement

--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Format datetime14. will not display seconds.

 

Format e8601dt16. will not display seconds.

 

And probably many others...

--
Paige Miller
shantanupl1
Obsidian | Level 7

Thank you.

But if I want the complete year then what should we do. Because using datetime14. will give the year values in 2 digit.

 

Thanks & Regards

Shantanu

PaigeMiller
Diamond | Level 26

e8601dt16.

 

Or, create your own custom format using the PICTURE statement

--
Paige Miller
shantanupl1
Obsidian | Level 7

Thank you. 

It worked using picture statement.

PaigeMiller
Diamond | Level 26

Yes, that's good to hear.

 

I never realized this particular deficiency of the DATETIME. format: you can't chop off the seconds and get 4 digits years.

--
Paige Miller
shantanupl1
Obsidian | Level 7

But if we create a picture format apply the format it converts the variable into a numeric variable not a date variable. Do you have any way to overcome this so that the variable should remain a Date variable after we apply the user defined format.

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 25. 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
  • 6 replies
  • 1702 views
  • 1 like
  • 2 in conversation