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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: