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.
Use the E8601DT19. informat to convert the string to a SAS datetime value, and assign the E8601DT19. format to the new variable.
Use the E8601DT19. informat to convert the string to a SAS datetime value, and assign the E8601DT19. format to the new variable.
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)
@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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.