<?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 How to calculate the difference between two timestamps of different obs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99757#M20982</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I have the following data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="125" style="border: 1px solid rgb(0, 0, 0); width: 458px; height: 125px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;ID&lt;/STRONG&gt;&lt;/P&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Status&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Timestamp&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;idle&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10MAY2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;active&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;15MAY2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;idle&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;25MAY2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;closed&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;01JUN2013&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Every time the status of an ID changes, a new record for that ID is being created and a timestamp of when the change occured is added to the record. That is how old statuses get historicized, as can be seen in the table. &lt;/P&gt;&lt;P&gt;I would like to add a column that measures how long a certain status has been assigned to an ID. The outcome would look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="124" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#575757&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;left&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#3366FF&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;}" style="border: 1px solid #000000; width: 794px; height: 106px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;ID&lt;/STRONG&gt;&lt;/P&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Status&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Timestamp&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="color: #ffffff; background-color: #6690bc; text-align: center; padding: 2px;"&gt;Duration in days&lt;/TH&gt;&lt;TH style="color: #ffffff; background-color: #6690bc; text-align: center; padding: 2px;"&gt;&lt;/TH&gt;&lt;TH style="color: #ffffff; background-color: #6690bc; text-align: center; padding: 2px;"&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;idle&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10MAY2013&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;active&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;15MAY2013&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;idle&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;25MAY2013&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;closed&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;01JUN2013&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The last value (the cell that contains "...") would be created through additional logic, like&lt;EM style="color: #575757;"&gt; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #575757;"&gt;if last.id then duration=today()-timestamp&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;or something like that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your help is much appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Oct 2013 15:26:01 GMT</pubDate>
    <dc:creator>PhilfromGermany</dc:creator>
    <dc:date>2013-10-01T15:26:01Z</dc:date>
    <item>
      <title>How to calculate the difference between two timestamps of different obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99757#M20982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I have the following data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="125" style="border: 1px solid rgb(0, 0, 0); width: 458px; height: 125px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;ID&lt;/STRONG&gt;&lt;/P&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Status&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Timestamp&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;idle&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10MAY2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;active&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;15MAY2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;idle&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;25MAY2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;closed&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;01JUN2013&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Every time the status of an ID changes, a new record for that ID is being created and a timestamp of when the change occured is added to the record. That is how old statuses get historicized, as can be seen in the table. &lt;/P&gt;&lt;P&gt;I would like to add a column that measures how long a certain status has been assigned to an ID. The outcome would look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="124" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#575757&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;left&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#3366FF&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;}" style="border: 1px solid #000000; width: 794px; height: 106px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;ID&lt;/STRONG&gt;&lt;/P&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Status&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Timestamp&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="color: #ffffff; background-color: #6690bc; text-align: center; padding: 2px;"&gt;Duration in days&lt;/TH&gt;&lt;TH style="color: #ffffff; background-color: #6690bc; text-align: center; padding: 2px;"&gt;&lt;/TH&gt;&lt;TH style="color: #ffffff; background-color: #6690bc; text-align: center; padding: 2px;"&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;idle&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10MAY2013&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;active&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;15MAY2013&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;idle&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;25MAY2013&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1122&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;closed&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;01JUN2013&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The last value (the cell that contains "...") would be created through additional logic, like&lt;EM style="color: #575757;"&gt; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #575757;"&gt;if last.id then duration=today()-timestamp&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;or something like that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your help is much appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Oct 2013 15:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99757#M20982</guid>
      <dc:creator>PhilfromGermany</dc:creator>
      <dc:date>2013-10-01T15:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between two timestamps of different obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99758#M20983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set have; by id;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;lastId = last.id;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if not endNext then &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have(firstobs=2 keep=timeStamp rename=(timeStamp=nextTimeStamp)) &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end=endNext;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if lastId &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then duration= intck("DAY", timeStamp, today());&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG&gt;else duration = intck('DAY', timeStamp, nextTimeStamp);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop lastId nextTimeStamp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: PG : Added END= condition to prevent premature datastep ending.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Oct 2013 17:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99758#M20983</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-10-01T17:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between two timestamps of different obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99759#M20984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A proc sql way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select a.*, b.timestamp-a.timestamp as duration&lt;/P&gt;&lt;P&gt;&amp;nbsp; from have a&lt;/P&gt;&lt;P&gt;left join have b&lt;/P&gt;&lt;P&gt;on a.id=b.id&lt;/P&gt;&lt;P&gt;and a.timestamp &amp;lt; b.timestamp&lt;/P&gt;&lt;P&gt;group by a.id, a.status, a.timestamp&lt;/P&gt;&lt;P&gt;having b.timestamp=min(b.timestamp) &lt;/P&gt;&lt;P&gt;&amp;nbsp; order by id,timestamp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Oct 2013 19:21:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99759#M20984</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-10-01T19:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between two timestamps of different obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99760#M20985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your dataset is already sorted by ID TIMESTAMP, then you can use the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not last.id then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=_N_+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have(rename=(timestamp=nextstamp) keep=nextstamp) point=i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; duration=intck('day', timestamp, nextstamp);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *drop nextstamp i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you may have to change the keep= set option to keep=timestamp. I always forget if rename applies before or after keep for set options. This effectively reads in the next TIMESTAMP into a new variable NEXTSTAMP using direct addressing of _N_+1 since your data is presorted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit the logic is very similar to that of PG&lt;/P&gt;&lt;P&gt;*edit corrected after PGs' comment. That is the kind of syntax restrictions that I always figure out debugging after my logic is established!&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Oct 2013 12:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99760#M20985</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-10-02T12:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between two timestamps of different obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99761#M20986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="818277" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="mailto:Vince28@Statcan"&gt;&lt;/A&gt;, that's a clever use of random access. However, expressions are not allowed as values to the POINT= option. You must use an intermediate variable to hold the expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Oct 2013 19:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99761#M20986</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-10-02T19:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between two timestamps of different obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99762#M20987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This involves double sorting, but if your data is not too big it might work....:)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt; length id 8 status $10 timestamp 8;&lt;BR /&gt; input id status timestamp anydtdte.;&lt;BR /&gt; format timestamp yymmdd10.;&lt;BR /&gt; datalines;&lt;BR /&gt; 1122 idle 10may2013&lt;BR /&gt; 1122 active 15may2013&lt;BR /&gt; 1122 idle 25may2013&lt;BR /&gt; 1122 closed 01jun2013&lt;BR /&gt; ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=test;&lt;BR /&gt; by id descending timestamp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;BR /&gt; set test;&lt;BR /&gt; retain tmp;&lt;BR /&gt; format nextts yymmdd10.;&lt;/P&gt;&lt;P&gt; if _n_ = 1 then tmp = .;&lt;BR /&gt; nextts = tmp;&lt;/P&gt;&lt;P&gt; if timestamp ne . then tmp = timestamp;&lt;/P&gt;&lt;P&gt; duration=intck('day', timestamp, nextts);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=new;&lt;BR /&gt; by id timestamp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 06:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-difference-between-two-timestamps-of/m-p/99762#M20987</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2013-10-03T06:35:05Z</dc:date>
    </item>
  </channel>
</rss>

