<?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 Simple Calculation Help in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Simple-Calculation-Help/m-p/124268#M10209</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to find the difference between 2 time stamps. If I have the columns Task and TimeStamp, I'm looking for the difference between TimeStamp of row n &amp;amp; of row (n-1). I can't do this in query builder, as I learned... I know that I can use the dif function or a lag function, but where would I put this? Would I need to make a new program to pull the needed data from the existing table and then make the calculation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish I could just use Excel!! Any help would be GREATLY appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 May 2012 01:49:52 GMT</pubDate>
    <dc:creator>TCy</dc:creator>
    <dc:date>2012-05-23T01:49:52Z</dc:date>
    <item>
      <title>Simple Calculation Help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Simple-Calculation-Help/m-p/124268#M10209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to find the difference between 2 time stamps. If I have the columns Task and TimeStamp, I'm looking for the difference between TimeStamp of row n &amp;amp; of row (n-1). I can't do this in query builder, as I learned... I know that I can use the dif function or a lag function, but where would I put this? Would I need to make a new program to pull the needed data from the existing table and then make the calculation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish I could just use Excel!! Any help would be GREATLY appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2012 01:49:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Simple-Calculation-Help/m-p/124268#M10209</guid>
      <dc:creator>TCy</dc:creator>
      <dc:date>2012-05-23T01:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Calculation Help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Simple-Calculation-Help/m-p/124269#M10210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DIF function is what you need here.&amp;nbsp; You put it in a data step, such as :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by timestamp;&lt;/P&gt;&lt;P&gt;time_dif=dif(timestamp);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This assumes that the dataset is sorted in timestamp order and that you don't have any other BY variables (e.g. Task).&amp;nbsp; I put the BY statement in so that the step would fail if the data wasn't sorted by timestamp.&amp;nbsp; You have to be careful if you are using IF or WHERE statements with DIF and LAG, it's worth reading the following article which describes the pitfalls you may encounter and how to resolve them.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #009933; font-family: arial, sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #009933; font-family: arial, sans-serif; font-size: 10pt;"&gt;&lt;A href="http://www.nesug.org/proceedings/nesug07/cc/cc33.pdf"&gt;www.nesug.org/proceedings/nesug07/cc/cc33.pdf&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2012 12:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Simple-Calculation-Help/m-p/124269#M10210</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2012-05-23T12:00:43Z</dc:date>
    </item>
  </channel>
</rss>

