<?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: Timestamp Manipulation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322616#M71398</link>
    <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt; Thank You for your solution, it worked.</description>
    <pubDate>Thu, 05 Jan 2017 09:42:16 GMT</pubDate>
    <dc:creator>ankit___gupta</dc:creator>
    <dc:date>2017-01-05T09:42:16Z</dc:date>
    <item>
      <title>Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322587#M71381</link>
      <description>&lt;P&gt;I have a date in the following format&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date1 = "05JAN2017:09:58:57.822"dt&lt;/P&gt;&lt;P&gt;I need to Subs tract 10 seconds from it. How to go about it ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please Help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 05:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322587#M71381</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-05T05:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322588#M71382</link>
      <description>&lt;P&gt;Use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date2 = intnx('seconds',date1,10);&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 05:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322588#M71382</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-05T05:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322591#M71383</link>
      <description>&lt;P&gt;What&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;proposes is the "clean" way of doing things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But just for your understanding:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;date1 = "05JAN2017:09:58:57.822"dt creates a SAS DateTime value which is numerical variable containing the number of seconds since 1/1/1960 - and as it's already in seconds and the variable is numerical you could also simply substract 10 seconds from it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;date2=date1-10;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 06:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322591#M71383</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-01-05T06:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322595#M71384</link>
      <description>&lt;P&gt;I will also suggest the same thing, you can direct substract 10 seconds from your date, because your date is already saved in datetime format.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 06:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322595#M71384</guid>
      <dc:creator>shubhayog</dc:creator>
      <dc:date>2017-01-05T06:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322600#M71386</link>
      <description>&lt;P&gt;Didn't work&lt;/P&gt;&lt;P&gt;It is Returning Null Value.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;%Let date1= "05JAN2017:09:58:57.822"dt;&lt;BR /&gt;%Let date2=;&lt;BR /&gt;data _null_;&lt;BR /&gt;date2 = intnx('seconds',&amp;amp;date1,10);&lt;BR /&gt;run;&lt;BR /&gt;%Put &amp;amp;date2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;date2 returns NULL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 07:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322600#M71386</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-05T07:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322601#M71387</link>
      <description>&lt;P&gt;Same solution as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Manjeet&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 07:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322601#M71387</guid>
      <dc:creator>mnjtrana</dc:creator>
      <dc:date>2017-01-05T07:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322602#M71388</link>
      <description>&lt;P&gt;It is not working&amp;nbsp;&lt;/P&gt;&lt;P&gt;Accoring to log it is returning NULL value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LOG:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;24 %Let date1= "05JAN2017:09:58:57.822"dt;&lt;BR /&gt;25 %Let date2=;&lt;BR /&gt;26 data _null_;&lt;BR /&gt;27 date2 = &amp;amp;date1 -10;&lt;BR /&gt;28 run;&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;29 %Put &amp;amp;date2;&lt;BR /&gt;&lt;BR /&gt;30&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 07:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322602#M71388</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-05T07:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322603#M71389</link>
      <description>&lt;P&gt;using &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;way, you will also get the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You just missed the call symput statement in your program, date2 macro variable is still assigned to null. Please note Date2 will be in SASDATE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%Let date1= "05JAN2017:09:58:57.822"dt;
data _null_;
date2 = intnx('seconds',&amp;amp;date1,10);
Call symputx('date2',date2);
run;
%Put &amp;amp;date1 ;
%put &amp;amp;date2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Manjeet&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 07:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322603#M71389</guid>
      <dc:creator>mnjtrana</dc:creator>
      <dc:date>2017-01-05T07:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322604#M71390</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/82369"&gt;@ankit___gupta&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You again missed the call symput. try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let date1= "05JAN2017:09:58:57.822"dt;
%Let date2=;
data _null_;
date2 = &amp;amp;date1 -10;
call symput ('date2',date2);
run;
%put &amp;amp;date2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jan 2017 07:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322604#M71390</guid>
      <dc:creator>mnjtrana</dc:creator>
      <dc:date>2017-01-05T07:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322610#M71394</link>
      <description>Got this as the output&lt;BR /&gt;29 %put &amp;amp;date2;&lt;BR /&gt;1799229527.8&lt;BR /&gt;&lt;BR /&gt;Converting to sasdate results in null.</description>
      <pubDate>Thu, 05 Jan 2017 08:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322610#M71394</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-05T08:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322612#M71396</link>
      <description>&lt;P&gt;To subrtact 10 seceonds from a timestamp, i.e. a datetime sas variable, you can do&lt;/P&gt;
&lt;P&gt;either by&amp;nbsp;&lt;STRONG&gt;date2 = date1 - 10;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;or by&amp;nbsp;&lt;STRONG&gt;date2 = intnx('seconds',date1, -10,'same');&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After calculating date2, if you want it as a macro variable you can do:&lt;/P&gt;
&lt;P&gt;either by&amp;nbsp;&lt;STRONG&gt;call symput('date2', date2); &amp;nbsp;&lt;/STRONG&gt;or by&amp;nbsp;&lt;STRONG&gt;call symput('date2', put(date2,best18.1));&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;or by &amp;nbsp;&lt;STRONG&gt;call syput('date2', '"' || put(date2, datetime18.1) ||'"dt');&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to check &amp;amp;date2, you can use&amp;nbsp;&lt;STRONG&gt;%put &amp;amp;date2;&lt;/STRONG&gt; but you shall get differen view each time.&lt;/P&gt;
&lt;P&gt;You can check by:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data _NULL_;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;date2 = &amp;amp;date2;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;put date2= &amp;nbsp;datetime18.1;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and check your log - you shall get same output, doesn't matter how you created that macro variable.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 09:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322612#M71396</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-05T09:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322614#M71397</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/82369"&gt;@ankit___gupta&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I'm a bit under the impression that you're probably asking for something that wouldn't be necessary to do and if you would give us the bigger picture and why you want to create such a second macro variable then we could eventually suggest other more direct ways to achieve the same end result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on the code you've posted and what you're asking for below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date1= "05JAN2017:09:58:57.822"dt;
data _null_;
  call symputx('date2',cats('"',put(&amp;amp;date1-10,datetime26.3),'"dt'));
run;
%put &amp;amp;=date1;
%put &amp;amp;=date2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jan 2017 09:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322614#M71397</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-01-05T09:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322616#M71398</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt; Thank You for your solution, it worked.</description>
      <pubDate>Thu, 05 Jan 2017 09:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322616#M71398</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-05T09:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Timestamp Manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322617#M71399</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; Requirement was to read the timestamp and reduce 10 sec from each. So i was unable to provide a broder picture.&lt;BR /&gt;&lt;BR /&gt;anyways Thanks a LOT !!&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jan 2017 09:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timestamp-Manipulation/m-p/322617#M71399</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-05T09:45:30Z</dc:date>
    </item>
  </channel>
</rss>

