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

Dear All,

 

I have a date time format for a variable as 2020-10-22T09:39:00 which is in character format with format as $19. and informat as $19.

 

Could you please help to convert this value into numeric format which should also be 2020-10-22T09:39:00 ?

 

I am working in unix environment.

1 ACCEPTED SOLUTION
3 REPLIES 3
r3570
Obsidian | Level 7

Hi Sir,

 

could you please also let me know how to convert the below:

 

2020-11-03 (in character format) to 2020-11-03T00:00:00 (character format) 

 

and 

 

2020-11-10T09:04 (character format) to 2020-11-10T09:04:00 (character format)

Kurt_Bremser
Super User

@r3570 wrote:

Hi Sir,

 

could you please also let me know how to convert the below:

 

2020-11-03 (in character format) to 2020-11-03T00:00:00 (character format) 

 

and 

 

2020-11-10T09:04 (character format) to 2020-11-10T09:04:00 (character format)


You do NOT store date or time values as character in SAS. You need more storage (numbers need only 8 bytes, and for dates you can reduce that to 4), and everytime you need to work with the values you have to convert them first. So you simply don't.

Exporting or printing them in a specific format is done at the time of export/report, and how they are displayed is determined by the assigned display format.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 1229 views
  • 2 likes
  • 2 in conversation