I have a date_time variable that is in B8601DZ35. format which I successfully separated to a date variable and a time variable. I have another variable that contains the GMT offset. I would like to adjust my date_time variable for this GMT offset.How would I go about this?
Date-Time GMT Offset
2017-01-11T14:30:04.365434911Z -5
2017-01-11T14:30:26.597592398Z -5
2017-01-11T14:44:08.071375241Z -5
2017-01-11T17:26:08.197434809Z -5
2017-01-11T13:00:05.983270062Z -5
2017-01-11T13:51:43.118027494Z -5
2017-01-11T14:30:04.346793673Z -5
2017-01-11T14:50:36.791404253Z -5
2017-01-11T14:50:46.555107131Z -5
2017-01-11T15:05:32.194165072Z -5
2017-01-11T15:05:32.258194133Z -5
2017-01-11T15:05:32.258194133Z -5
2017-01-11T15:05:32.258194133Z -5
2017-01-11T15:05:48.638213623Z -5
2017-01-11T15:05:49.242262429Z -5
2017-01-11T15:05:49.242262429Z -5
2017-01-11T15:05:52.334463850Z -5
2017-01-11T15:05:52.718504205Z -5
here is an example of the data. Thanks
As long as you have a datetime variable in a dt SAS format, you should be able to use the intnx function to shift the stamp by the value in GMT_Offset:
new_dt=intnx('hour',date_time,GMT_Offset,'s')
Edit: I typed intck and meant intnx - duh.
As long as you have a datetime variable in a dt SAS format, you should be able to use the intnx function to shift the stamp by the value in GMT_Offset:
new_dt=intnx('hour',date_time,GMT_Offset,'s')
Edit: I typed intck and meant intnx - duh.
Thanks. I worked it out this way too. Just a quick question. How can I get millisecond from a time variable ?
You can get the decimal portion of seconds of a datetime in a data step as:
decimal = datetime - floor(datetime);
since datetimes are stored as seconds.
Depending on which part of the value you want and how you want it multiplication, division and or round, floor or ceil functions may come into play.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.