BookmarkSubscribeRSS Feed
gzr2mz39
Quartz | Level 8
I have a variable with the following three observations in datetime format.
'11OCT2010:10:28:47'
'17OCT2010:12:21:47'
'27OCT2010:16:14:47'
These date times are in UTC (coordinated universal time). I would like to convert them to PST (pacific standard).
Does SAS have a tool for converting date time values to other time zones?
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
No specific "tool" - you need only use some data condition to test (revealing the time-zone), and then use a DATA step (or PROC SQL) programming technique to adjust (either increment or decrement) the SAS DATETIME variable value.

One example using a SAS assignment statement within a DATA step:

data _null_;
format UTC_DT Local_DT DATETIME21. ;
UTC_DT = datetime(); /* assign current SAS datetime var */
if () then TimeZoneOffset = -"5:00:00"t;
else if () then TimeZoneOffset = -"6:00:00"t;
else do;
* unknown condition code - abort maybe? ;
end;
Local_DT = SUM(UTC_DT,TimeZoneOffset);
putlog _all_;
run;


Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

date datetime variables site:sas.com
ArtC
Rhodochrosite | Level 12
Under Windows and Unix there is the TZ environment variable that might prove to be useful. Take a look at:
http://www.lexjansen.com/pharmasug/2010/sas/sas-tt-sas01.pdf

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 6631 views
  • 0 likes
  • 3 in conversation