<?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: Creating a new variable calculated from values of different lines in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82181#M563</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can't you just use the lag function?&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname art "c:\art";&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format difference time8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set art.inter;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by datum name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; last_last=lag(last);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.name then call missing(last_last);&lt;/P&gt;&lt;P&gt;&amp;nbsp; difference=first-last_last;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Nov 2012 19:22:28 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-11-27T19:22:28Z</dc:date>
    <item>
      <title>Creating a new variable calculated from values of different lines</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82180#M562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear SAS experts, In my data set (animal behavior) I would like to create a new variable:&amp;nbsp; the time interval between two events. There exists the variables 'first (starting time of&amp;nbsp; behavior)’ and 'Last (ending time of behavior)' per line (see attached table). I am interested in the time interval between 'last' in line n and 'first' in line n + 1. I really appreciate your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 19:12:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82180#M562</guid>
      <dc:creator>Engel</dc:creator>
      <dc:date>2012-11-27T19:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable calculated from values of different lines</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82181#M563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can't you just use the lag function?&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname art "c:\art";&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format difference time8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set art.inter;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by datum name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; last_last=lag(last);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.name then call missing(last_last);&lt;/P&gt;&lt;P&gt;&amp;nbsp; difference=first-last_last;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 19:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82181#M563</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-27T19:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable calculated from values of different lines</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82182#M564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Arthur, thank you very much! It is exactly what I wanted. Best regards from Germany Engel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 19:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82182#M564</guid>
      <dc:creator>Engel</dc:creator>
      <dc:date>2012-11-27T19:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable calculated from values of different lines</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82183#M565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Echo with Art, you can also use dif(); sorry, Art, for stealing your code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format difference time8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set art.inter;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by datum name;&lt;/P&gt;&lt;P&gt;/*&amp;nbsp; last_last=lag(last);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.name then call missing(last_last);*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; difference=ifn(first.name,.,dif(last));&lt;/P&gt;&lt;P&gt;run;&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, 27 Nov 2012 19:35:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82183#M565</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-27T19:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable calculated from values of different lines</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82184#M566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="5068" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: I don't mind your "stealing" the code, but your solution doesn't meet the OP's requirements.&amp;nbsp; You are taking the difference between last and the previous last.&amp;nbsp; The OP wanted the difference between the current first and the previous last.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 20:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82184#M566</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-27T20:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable calculated from values of different lines</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82185#M567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oops, my bad. Now I know why you choose to use lag(). Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 21:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Creating-a-new-variable-calculated-from-values-of-different/m-p/82185#M567</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-27T21:20:51Z</dc:date>
    </item>
  </channel>
</rss>

