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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2001 views
  • 1 like
  • 2 in conversation