<?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: How to perform Arithmetic operations with Operators in the dataset. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714675#M220667</link>
    <description>&lt;P&gt;The normal numeric informat will convert those strings into numbers just fine.&amp;nbsp; So this will create a numeric variable OFFSET with the number of hours (positive or negative).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;offset=input(zone,32.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could then use INTNX() function or simple arithmetic to add the offset value to your current datetime value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;universal_dt = intnx('hour',datetime,offset,'s');
universal_dt = datetime + offset*'01:00't ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Jan 2021 17:19:00 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-01-27T17:19:00Z</dc:date>
    <item>
      <title>How to perform Arithmetic operations with Operators in the dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714655#M220653</link>
      <description>&lt;P&gt;Hi Community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to work on adding a datetime variable to adjust for a time zone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;DateTime	        Zone 
31OCT19:18:08:00	+02
05NOV19:06:00:00	+02
05NOV19:12:15:00	-05
08NOV19:20:30:00	+02
13NOV19:12:52:00	+08
15NOV19:17:44:00	+02
18NOV19:14:33:00	-05
20NOV19:06:21:00	+02
20NOV19:14:22:00	+08
22NOV19:14:25:00	+02&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The issue is that the observations already have the arithmetic operators in the values. I need help in adding the Zone variable(Hours) to the Datetime variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 16:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714655#M220653</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2021-01-27T16:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform Arithmetic operations with Operators in the dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714663#M220656</link>
      <description>&lt;P&gt;is zone numeric or character?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 16:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714663#M220656</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-27T16:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform Arithmetic operations with Operators in the dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714664#M220657</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input  DateTime :datetime20.	        Zone $;
format datetime datetime20.;
cards; 
31OCT19:18:08:00	+02
05NOV19:06:00:00	+02
05NOV19:12:15:00	-05
08NOV19:20:30:00	+02
13NOV19:12:52:00	+08
15NOV19:17:44:00	+02
18NOV19:14:33:00	-05
20NOV19:06:21:00	+02
20NOV19:14:22:00	+08
22NOV19:14:25:00	+02
;

data want;
 set have;
 k=sign(input(zone,8.));
 New_DateTime=sum(datetime,k,hms(abs(k),0,0));
 format New_datetime datetime20.;
 drop k;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/110575"&gt;@shasank&lt;/a&gt;&amp;nbsp; I overlooked the data by mistake and so I have edited&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 16:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714664#M220657</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-01-27T16:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform Arithmetic operations with Operators in the dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714665#M220658</link>
      <description>It is in a character format.</description>
      <pubDate>Wed, 27 Jan 2021 16:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714665#M220658</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2021-01-27T16:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform Arithmetic operations with Operators in the dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714668#M220660</link>
      <description>&lt;P&gt;Please show what you expect the value results to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might guess that you want something similar to this assuming your current datetime variable is actually a SAS datetime value, numeric with a datetime format assigned.&lt;/P&gt;
&lt;PRE&gt;data have;
   input DateTime datetime.  Zone $;
   format datetime datetime16.;
datalines;
31OCT19:18:08:00	+02
05NOV19:06:00:00	+02
05NOV19:12:15:00	-05
08NOV19:20:30:00	+02
13NOV19:12:52:00	+08
15NOV19:17:44:00	+02
18NOV19:14:33:00	-05
20NOV19:06:21:00	+02
20NOV19:14:22:00	+08
22NOV19:14:25:00	+02
;

data want;
   set have;
   datetime = intnx('hour',datetime,input(zone,best.),'s');
run;&lt;/PRE&gt;
&lt;P&gt;The INTNX function increments time, date or datetime values by a given interval, 'hour' in this case. The Input turns the zone into a numeric value assuming hours, and the 'S' parameter means "same" for keeping minutes.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 17:01:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714668#M220660</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-27T17:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform Arithmetic operations with Operators in the dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714669#M220661</link>
      <description>Have a look at how SAS supports adjusting for timezones  at documentation.sas.com .... programming in sas9.4 &lt;BR /&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=nlsref&amp;amp;docsetTarget=p12pvfgfm152jhn1r9b1u1rl8ut8.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=nlsref&amp;amp;docsetTarget=p12pvfgfm152jhn1r9b1u1rl8ut8.htm&amp;amp;locale=en&lt;/A&gt;</description>
      <pubDate>Wed, 27 Jan 2021 17:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714669#M220661</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2021-01-27T17:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform Arithmetic operations with Operators in the dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714675#M220667</link>
      <description>&lt;P&gt;The normal numeric informat will convert those strings into numbers just fine.&amp;nbsp; So this will create a numeric variable OFFSET with the number of hours (positive or negative).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;offset=input(zone,32.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could then use INTNX() function or simple arithmetic to add the offset value to your current datetime value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;universal_dt = intnx('hour',datetime,offset,'s');
universal_dt = datetime + offset*'01:00't ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jan 2021 17:19:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714675#M220667</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-27T17:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform Arithmetic operations with Operators in the dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714677#M220669</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set test;
 length Zone $3.;

	Zone = substr(DF_datetime,max(1,length(DF_datetime)-2));

	k = sign(input(Zone,8.));
 DF_deldttm =sum(DF_deldttm,a,hms(abs(k),0,0));

 format DF_deldttm  datetime.;
		 
run;

Output: 
Date/time of delivery, DF	Zone	a	Datetime
31OCT19:18:08:00	2	1	31OCT19:19:08:01
05NOV19:06:00:00	2	1	05NOV19:07:00:01
05NOV19:12:15:00	-5	-1	05NOV19:13:14:59
08NOV19:20:30:00	2	1	08NOV19:21:30:01
13NOV19:12:52:00	8	1	13NOV19:13:52:01
15NOV19:17:44:00	2	1	15NOV19:18:44:01
18NOV19:14:33:00	-5	-1	18NOV19:15:32:59
20NOV19:06:21:00	2	1	20NOV19:07:21:01
20NOV19:14:22:00	8	1	20NOV19:15:22:01
22NOV19:14:25:00	2	1	22NOV19:15:25:01
The zone variable is going off. 

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jan 2021 17:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714677#M220669</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2021-01-27T17:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform Arithmetic operations with Operators in the dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714679#M220670</link>
      <description>&lt;P&gt;Take the solution given by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; or&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 17:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operations-with-Operators-in-the/m-p/714679#M220670</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-01-27T17:24:16Z</dc:date>
    </item>
  </channel>
</rss>

