<?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: Formatting Hours - adding 3 hours to variable/date in data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588063#M168013</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289716"&gt;@sasxii&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Would I do it in a proc format?&lt;BR /&gt;&lt;BR /&gt;proc format;&lt;BR /&gt;DATE = DATE + 10800;&lt;BR /&gt;run;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This can only be done in a SAS DATA step. It cannot be done in PROC FORMAT.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since Proc Format will now allow use of functions from Proc Fcmp a specific value such as adding 10800 seconds or similar could be used in a format.&amp;nbsp;Whether it is a good idea may be questioned for many purposes. The example in the documentation shows creating two formats to convert temperatures from Celsius to Fahrenheit and Fahrenheit to Celsius which do the numeric conversion and show an appropriate C or F at the end.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Sep 2019 23:26:48 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-09-11T23:26:48Z</dc:date>
    <item>
      <title>Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588001#M167979</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a date format in&amp;nbsp;DATETIME18. and would like to add three hours to it to reflect a timezone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EX.&amp;nbsp;&lt;/P&gt;&lt;P&gt;12/31/2018 8:13:55 AM will become&amp;nbsp;12/31/2018 11:13:55 AM in the column for all the variables that fall under that column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would you do this? At the moment I have already put my data in and it is listed as data1 with the date column being 'DATE' .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 19:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588001#M167979</guid>
      <dc:creator>sasxii</dc:creator>
      <dc:date>2019-09-11T19:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588002#M167980</link>
      <description>&lt;P&gt;Three hours is 3*60*60 = 10800 seconds. So you would add 10800 to the date/time variable.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 19:59:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588002#M167980</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-11T19:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588003#M167981</link>
      <description>&lt;P&gt;so would it be&amp;nbsp;DATETIME18. + hours converted to seconds?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 20:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588003#M167981</guid>
      <dc:creator>sasxii</dc:creator>
      <dc:date>2019-09-11T20:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588004#M167982</link>
      <description>&lt;P&gt;If the variable is named DATE then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date = date + 10800;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Sep 2019 20:04:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588004#M167982</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-11T20:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588009#M167984</link>
      <description>Would I do it in a proc format?&lt;BR /&gt;&lt;BR /&gt;proc format;&lt;BR /&gt;DATE = DATE + 10800;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 11 Sep 2019 20:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588009#M167984</guid>
      <dc:creator>sasxii</dc:creator>
      <dc:date>2019-09-11T20:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588010#M167985</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289716"&gt;@sasxii&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Would I do it in a proc format?&lt;BR /&gt;&lt;BR /&gt;proc format;&lt;BR /&gt;DATE = DATE + 10800;&lt;BR /&gt;run;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This can only be done in a SAS DATA step. It cannot be done in PROC FORMAT.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 20:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588010#M167985</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-11T20:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588012#M167987</link>
      <description>&lt;P&gt;NOTE: If you have a datetime value it is going to be confusing to refer to it as a DATE.&amp;nbsp; DATE values are stored in number of days and DATETIME and TIME values are stored in number of seconds.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the INTNX() function to change date/time/datetime values by specific intervals.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;intnx('hour',datetime_var,3,'same')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use time literal to add three hours.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datetime_var + '03:00't&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could just add the right number of seconds.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datetime_var + 3*60*60 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In terms of reflecting timezone I would assume that you need some type of test of what timezone the current value represents to get the right number of hours added.&amp;nbsp; So perhaps you data step will look something like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  if timezone='PT' then datetimevar=datetimevar + '03:00't ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 20:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588012#M167987</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-11T20:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588014#M167989</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289716"&gt;@sasxii&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;so would it be&amp;nbsp;DATETIME18. + hours converted to seconds?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That doesn't make much sense.&lt;/P&gt;
&lt;P&gt;DATETIME18. is a format specification, like DOLLAR10.2 or BEST12., not an actual datetime value.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 20:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588014#M167989</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-11T20:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588015#M167990</link>
      <description>what happens if I the value is not by a specific interval? how would this be done then?</description>
      <pubDate>Wed, 11 Sep 2019 20:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588015#M167990</guid>
      <dc:creator>sasxii</dc:creator>
      <dc:date>2019-09-11T20:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588022#M167994</link>
      <description>&lt;P&gt;Another possibility:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 /* Recreating your datetime variable */
  have=dhms('31DEC2018'd,8,13,55);

 /* adding 3 hours */
  want=dhms(datepart(have),hour(have)+3,minute(have),second(have));

 format have want dateampm22.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Sep 2019 20:34:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588022#M167994</guid>
      <dc:creator>ChanceTGardener</dc:creator>
      <dc:date>2019-09-11T20:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588023#M167995</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289716"&gt;@sasxii&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;what happens if I the value is not by a specific interval? how would this be done then?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Replace 3 in the formula with the name of the variable that has the number of hours you want to change by.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 20:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588023#M167995</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-11T20:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588063#M168013</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289716"&gt;@sasxii&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Would I do it in a proc format?&lt;BR /&gt;&lt;BR /&gt;proc format;&lt;BR /&gt;DATE = DATE + 10800;&lt;BR /&gt;run;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This can only be done in a SAS DATA step. It cannot be done in PROC FORMAT.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since Proc Format will now allow use of functions from Proc Fcmp a specific value such as adding 10800 seconds or similar could be used in a format.&amp;nbsp;Whether it is a good idea may be questioned for many purposes. The example in the documentation shows creating two formats to convert temperatures from Celsius to Fahrenheit and Fahrenheit to Celsius which do the numeric conversion and show an appropriate C or F at the end.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 23:26:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588063#M168013</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-11T23:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588162#M168061</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289716"&gt;@sasxii&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;what happens if I the value is not by a specific interval? how would this be done then?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you mean sometimes it might be 6 hours instead of 3 hours? The same method would be used.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 10:47:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588162#M168061</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-12T10:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Hours - adding 3 hours to variable/date in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588228#M168086</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;next_time = intnx('hours', originalVariable, incrementVariable);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use variables in the INTNX() function which seems appropriate.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289716"&gt;@sasxii&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;what happens if I the value is not by a specific interval? how would this be done then?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 13:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Hours-adding-3-hours-to-variable-date-in-data/m-p/588228#M168086</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-12T13:49:06Z</dc:date>
    </item>
  </channel>
</rss>

