After I import the file, there is a column:
Start date
28MAR18:13:00:53
28MAR18:13:01:30
02APR18:14:23:14
02APR18:14:23:14
...
I want to calculate a new column to convert the column above to seconds, how can I do that?
Is your datetime variable a numeric one just formatted with datetime format or is it a char?
If it is formatted, remove the format , you will see the number of seconds since January 1, 1960.
Or if you are looking to extract seconds from the datetime value, use second function
s=second(datetime);
It is not numeric, it is char. This is the reason I cannot convert them into seconds.
Aah ok,
newvar= input(datetime, datetime20.);
will give you numeric datetime value
@y_fu wrote:
It is not numeric, it is char. This is the reason I cannot convert them into seconds.
Still better: use the datetime18. informat when reading the external file..
@y_fu wrote:
It is not numeric, it is char. This is the reason I cannot convert them into seconds.
Seconds from when?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.