<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Do SAS datasets have a timezone attribute for datetimes? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532782#M146012</link>
    <description>&lt;P&gt;I think the dataset timestamp is UTC and reported by proc contents according to your locale, as demonstrated by:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options tz='America/New_York';
data ny;
Hello = "World";
run;

proc contents data = ny; run;

options tz='Asia/Shanghai';
proc contents data = ny; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                               The CONTENTS Procedure

    Data Set Name        WORK.NY                       Observations          1
    Member Type          DATA                          Variables             1
    Engine               V9                            Indexes               0
    Created              2019-02-04 17:01:13           Observation Length    5
    Last Modified        2019-02-04 17:01:13           Deleted Observations  0
.
.
.
                               The CONTENTS Procedure

    Data Set Name        WORK.NY                       Observations          1
    Member Type          DATA                          Variables             1
    Engine               V9                            Indexes               0
    Created              2019-02-05 06:01:13           Observation Length    5
    Last Modified        2019-02-05 06:01:13           Deleted Observations  0
...&lt;/PRE&gt;</description>
    <pubDate>Mon, 04 Feb 2019 22:08:22 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2019-02-04T22:08:22Z</dc:date>
    <item>
      <title>Do SAS datasets have a timezone attribute for datetimes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532734#M145995</link>
      <description>&lt;P&gt;I'm trying to get the hang of working with SAS timezones.&amp;nbsp; Bottom of Page 42,&amp;nbsp;&amp;nbsp;&lt;A href="https://documentation.sas.com/api/docsets/nlsref/9.4/content/nlsref.pdf?locale=en#nameddest=n0px72paaaqx06n1ozps024j78cl" target="_self"&gt;SAS&amp;nbsp;NLS: Reference&lt;/A&gt;, 5th Ed. states:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;"When you specify a time zone, SAS adds a time-zone-specific timestamp to data sets and SAS catalogs when the data set or catalog is created or modified".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following calls the datetime() and&amp;nbsp; &lt;CODE class=" language-sas"&gt;tzones2u()&amp;nbsp;&lt;/CODE&gt;functions, which are influenced by the timezone option in effect:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: This session is executing on the X64_10PRO  platform.

1          %let dt_fmt = dateampm.;
2          
3          options tz='America/New_York';
4          data ny;
5             ny_dt     = datetime();
6             ny_2_utc  = tzones2u(ny_dt);
7             *ny_tz_off = cat(put(tzoneoff(ny_dt) / 3600, 8.), ':00');
8          run;

NOTE: The data set WORK.NY has 1 observations and 2 variables.     

9          
10         options tz='Asia/Shanghai';
11         data sha;
12            sha_dt    = datetime();
13            sha_2_utc = tzones2u(sha_dt);
14            *sha_tz_off = cat(put(tzoneoff(sha_dt) / 3600, 8.), ':00');;
15         run;

NOTE: The data set WORK.SHA has 1 observations and 2 variables.

16         
17         options tz='America/New_York';
18         data both;
19            merge ny
20                  sha;
21         diff = intck('hour', ny_dt, sha_dt, 'Continuous');
22         
23         put 'New York Datetime:      ' ny_dt     &amp;amp;dt_fmt  /
24         	'New York 2 UTC:         ' ny_2_utc  &amp;amp;dt_fmt //
25             'Shanghai Datetime:      ' sha_dt    &amp;amp;dt_fmt  /
26             'Shanghai 2 UTC:         ' sha_2_utc &amp;amp;dt_fmt //
27         'Time Difference NY and SHA: ' diff ' Hours';
28         run;

New York Datetime:      04FEB19:02:10:23 PM
New York 2 UTC:         04FEB19:07:10:23 PM

Shanghai Datetime:      05FEB19:03:10:23 AM
Shanghai 2 UTC:         04FEB19:07:10:23 PM

Time Difference NY and SHA: 13  Hours

29         
30         proc contents data = ny;run;
31         proc contents data = sha;run;

NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The output from PROC CONTENTS does not appear to display such an attribute.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                                      The CONTENTS Procedure

           Data Set Name        WORK.NY                       Observations          1 
           Member Type          DATA                          Variables             2 
           Engine               V9                            Indexes               0 
           Created              02/04/2019 14:10:23           Observation Length    16
           Last Modified        02/04/2019 14:10:23           Deleted Observations  0 
           Protection                                         Compressed            NO
           Data Set Type                                      Sorted                NO
           Label                                                                      
           Data Representation  WINDOWS_64                                            
           Encoding             wlatin1  Western (Windows)                            


                                Engine/Host Dependent Information

Data Set Page Size          65536                                                                 
Number of Data Set Pages    1                                                                     
First Data Page             1                                                                     
Max Obs per Page            4062                                                                  
Obs in First Data Page      1                                                                     
Number of Data Set Repairs  0                                                                     
ExtendObsCounter            YES                                                                   
Filename                    C:\Users\randy\AppData\Local\Temp\SAS Temporary                       
                            Files\_TD9972_RANDY-PC_\ny.sas7bdat                                   
Release Created             9.0401M5                                                              
Host Created                X64_10PRO                                                             
Owner Name                  randy-PC\randy                                                        
File Size                   128KB                                                                 
File Size (bytes)           131072                                                                


                            Alphabetic List of Variables and Attributes
 
                                   #    Variable    Type    Len

                                   2    ny_2_utc    Num       8
                                   1    ny_dt       Num       8


                                      The CONTENTS Procedure

           Data Set Name        WORK.SHA                      Observations          1 
           Member Type          DATA                          Variables             2 
           Engine               V9                            Indexes               0 
           Created              02/04/2019 14:10:23           Observation Length    16
           Last Modified        02/04/2019 14:10:23           Deleted Observations  0 
           Protection                                         Compressed            NO
           Data Set Type                                      Sorted                NO
           Label                                                                      
           Data Representation  WINDOWS_64                                            
           Encoding             wlatin1  Western (Windows)                            


                                Engine/Host Dependent Information

Data Set Page Size          65536                                                                 
Number of Data Set Pages    1                                                                     
First Data Page             1                                                                     
Max Obs per Page            4062                                                                  
Obs in First Data Page      1                                                                     
Number of Data Set Repairs  0                                                                     
ExtendObsCounter            YES                                                                   
Filename                    C:\Users\randy\AppData\Local\Temp\SAS Temporary                       
                            Files\_TD9972_RANDY-PC_\sha.sas7bdat                                  
Release Created             9.0401M5                                                              
Host Created                X64_10PRO                                                             
Owner Name                  randy-PC\randy                                                        
File Size                   128KB                                                                 
File Size (bytes)           131072                                                                


                           Alphabetic List of Variables and Attributes
 
                                  #    Variable     Type    Len

                                  2    sha_2_utc    Num       8
                                  1    sha_dt       Num       8&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If someone supplies a dataset with datetime values created with a SAS instance where the timezone in effect is unknown, then how would I convert the incoming datatimes to a timezone other than the timezone in effect in this current instance of SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Randy&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 20:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532734#M145995</guid>
      <dc:creator>rbetancourt</dc:creator>
      <dc:date>2019-02-04T20:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Do SAS datasets have a timezone attribute for datetimes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532782#M146012</link>
      <description>&lt;P&gt;I think the dataset timestamp is UTC and reported by proc contents according to your locale, as demonstrated by:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options tz='America/New_York';
data ny;
Hello = "World";
run;

proc contents data = ny; run;

options tz='Asia/Shanghai';
proc contents data = ny; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                               The CONTENTS Procedure

    Data Set Name        WORK.NY                       Observations          1
    Member Type          DATA                          Variables             1
    Engine               V9                            Indexes               0
    Created              2019-02-04 17:01:13           Observation Length    5
    Last Modified        2019-02-04 17:01:13           Deleted Observations  0
.
.
.
                               The CONTENTS Procedure

    Data Set Name        WORK.NY                       Observations          1
    Member Type          DATA                          Variables             1
    Engine               V9                            Indexes               0
    Created              2019-02-05 06:01:13           Observation Length    5
    Last Modified        2019-02-05 06:01:13           Deleted Observations  0
...&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Feb 2019 22:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532782#M146012</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-02-04T22:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Do SAS datasets have a timezone attribute for datetimes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532787#M146015</link>
      <description>&lt;P&gt;Very interesting question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think there is not flag or "stamp" or attribute set or added anywhere. So this can be a misread:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"When you specify a time zone, SAS adds a time-zone-specific timestamp to data sets and SAS catalogs when the data set or catalog is created or modified".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What happens as far as I understand is that if time zones are known &lt;U&gt;in the SAS session&lt;/U&gt;, SAS uses that information to shift the datetime values. This shift takes place both when storing values (as you have shown) and when retrieving them (as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;showed).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 22:16:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532787#M146015</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-02-04T22:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Do SAS datasets have a timezone attribute for datetimes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532800#M146028</link>
      <description>&lt;P&gt;Thanks to both&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp; for the helpful responses.&amp;nbsp; And I verified it with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;4  options tz='America/New_York';
5  data both;
6     merge ny
7           sha;
8  diff = intck('hour', ny_dt, sha_dt, 'Continuous');
9
10  sha_tzone_off_now = cat(put(tzoneoff(sha_dt) / 3600, 8.), ':00');
11
12  put 'New York Datetime:      ' ny_dt     &amp;amp;dt_fmt  /
13      'New York 2 UTC:         ' ny_2_utc  &amp;amp;dt_fmt //
14      'Shanghai Datetime:      ' sha_dt    &amp;amp;dt_fmt  /
15      'Sha TZ offset then:     ' sha_tz_off_then    /
16      'Sha TZ offset now:      ' sha_tz_off_then    //
17      'Shanghai 2 UTC:         ' sha_2_utc &amp;amp;dt_fmt /
18  'Time Difference NY and SHA: ' diff ' Hours';
19  run;

New York Datetime:      04FEB19:05:16:44 PM
New York 2 UTC:         04FEB19:10:16:44 PM

Shanghai Datetime:      05FEB19:06:16:44 AM
Sha TZ offset then:     8:00
Sha TZ offset now:      8:00

Shanghai 2 UTC:         04FEB19:10:16:44 PM
Time Difference NY and SHA: 13  Hours&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Feb 2019 22:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532800#M146028</guid>
      <dc:creator>rbetancourt</dc:creator>
      <dc:date>2019-02-04T22:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Do SAS datasets have a timezone attribute for datetimes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532802#M146029</link>
      <description>&lt;P&gt;I reported this documentation error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The value is shifted. &amp;nbsp;No “&lt;STRONG&gt;time-zone-specific timestamp” &lt;/STRONG&gt;is&lt;STRONG&gt; “added”.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 22:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/532802#M146029</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-02-04T22:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Do SAS datasets have a timezone attribute for datetimes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/539172#M148507</link>
      <description>&lt;P&gt;Good news. The documentation is being revised.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From:&lt;/P&gt;
&lt;P&gt;When you specify a time zone, SAS adds a time-zone-specific timestamp to data sets and SAS catalogs when the data set or catalog is created or modified.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The time-zone-specific timestamp is also added to the SAS log when SAS starts and to the output at execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To:&lt;/P&gt;
&lt;P&gt;When you specify a time zone, SAS shifts the datetime value according to the time zone and stores the new value.&lt;/P&gt;
&lt;P&gt;The time-zone-specific timestamp is displayed to the SAS log.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 22:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/539172#M148507</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-02-27T22:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Do SAS datasets have a timezone attribute for datetimes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/539404#M148618</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;, thank you for the follow-up!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2019 17:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-SAS-datasets-have-a-timezone-attribute-for-datetimes/m-p/539404#M148618</guid>
      <dc:creator>rbetancourt</dc:creator>
      <dc:date>2019-02-28T17:37:25Z</dc:date>
    </item>
  </channel>
</rss>

