What function can I use to change:
2014-07-09 11:42:34:826 --> 2014-07-09 11:42:34
Is that value stored in a numeric or character SAS variable? If it is numeric, what format is applied to it?
SAS Datetime values are integers until the milliseconds part. So given that your values are actual numeric datetime values, you can use the Floor or Round Function depending on what you want.
Or you can find an appropriate SAS format if you do not want to change the actual values.
SAS datetime values are stored as the count of seconds since 1/1/1960. They are stored in a numerical values, can include fractional seconds and you can use any operator that's suitable for numerical values.
In your case: If you would want to round to seconds shouldn't the formatted value be 2014-07-09 11:42:35
Given your dealing with a numerical variable and depending what you want use either of the following functions:
- round()
- int()
- floor()
- ceil()
These functions area all documented under: https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/n01f5qrjoh9h4hn1olbdpb5pr2t...
One of them will give you exactly what you want.
And last but not least: If it's just about printing the internal value without fractional seconds then use DATETIME22. ...but be aware that this will use arithmetic rounding so it will be 35 seconds.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.