I have the date and time in Char as below
Date and time |
2017-03-01T12:10 |
2017-03-01T13:02 |
2017-03-07T22:15 |
2017-03-19T09:32 |
2017-04-12T11:45 |
I want to converted to date and time into Numeric
What is the best way to handle this coversion?
THANKS!!
If you change the code, then it might not work. If you use the exact code I provided, I know that it does work.
You use the INPUT() function with the proper informat.
Example:
num_date_time=input(char_date_time,e8601dt.);
You may also want to apply a format to num_date_time.
num_date_time=input(char_date_time,datetime.);
I tried to convert using input as above, but it did not work (probably because there is a "T" in the character string to separate the date and time).
If you change the code, then it might not work. If you use the exact code I provided, I know that it does work.
The T between the date and time portion means that the DATETIME informat will not work as that expects a single punctuation character such as colon, space or slash. The T indicatess a separate ISO layout hence the different informat.
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!
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.