BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
somebody
Lapis Lazuli | Level 10

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 

1 ACCEPTED SOLUTION

Accepted Solutions
bobpep212
Quartz | Level 8

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. 

View solution in original post

3 REPLIES 3
bobpep212
Quartz | Level 8

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. 

somebody
Lapis Lazuli | Level 10

Thanks. I worked it out this way too. Just a quick question. How can I get millisecond from a time variable ?

 

ballardw
Super User

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1978 views
  • 0 likes
  • 3 in conversation