<?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: Difference of a value from one variable and the lead of another value in the same variable?? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-of-a-value-from-one-variable-and-the-lead-of-another/m-p/768406#M243732</link>
    <description>&lt;P&gt;By&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;"difference between dp at number 1 and rp at value at next number".&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you want the rp test value minus the dp test value for each number.&amp;nbsp; If so, then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge  have (where=(tst='dp') rename=test_rt=dp_test)
         have (where=(tst='rp') rename=test_rt=rp_test);
  by number;
  rp_minus_dp=rp_test-dp_test;
  drop tst ;
  if last.number;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that's not what you mean, please show what the results would look like for the data you provided.&lt;/P&gt;</description>
    <pubDate>Sat, 18 Sep 2021 05:11:14 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2021-09-18T05:11:14Z</dc:date>
    <item>
      <title>Difference of a value from one variable and the lead of another value in the same variable??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-of-a-value-from-one-variable-and-the-lead-of-another/m-p/768338#M243707</link>
      <description>&lt;P&gt;Here is how my sample data looks like&lt;/P&gt;&lt;P&gt;ID$ Tst$ test_rt number&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; dp&amp;nbsp; &amp;nbsp; 20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; rp&amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; dp&amp;nbsp; &amp;nbsp; 35&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; rp&amp;nbsp; &amp;nbsp; &amp;nbsp;20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; dp&amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; rp&amp;nbsp; &amp;nbsp; &amp;nbsp; 20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to have an algorithm setup for calculating the difference between dp at number 1 and rp at value at next number?? Did any one encounter such situations, If so how to tackle that?? Please suggest, Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 17:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-of-a-value-from-one-variable-and-the-lead-of-another/m-p/768338#M243707</guid>
      <dc:creator>sandhya88</dc:creator>
      <dc:date>2021-09-17T17:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of a value from one variable and the lead of another value in the same variable??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-of-a-value-from-one-variable-and-the-lead-of-another/m-p/768340#M243709</link>
      <description>&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID$ Tst$ test_rt number;
cards;
1 dp 20 1
1 rp 0 1
1 dp 35 2
1 rp 20 2
1 dp 0 3
1 rp 20 3
;

 
data want;
set have;
by number notsorted;
retain new_number;
if first.number then new_number=test_rt;
if last.number then dif=test_rt -new_number;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Sep 2021 18:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-of-a-value-from-one-variable-and-the-lead-of-another/m-p/768340#M243709</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2021-09-17T18:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of a value from one variable and the lead of another value in the same variable??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-of-a-value-from-one-variable-and-the-lead-of-another/m-p/768406#M243732</link>
      <description>&lt;P&gt;By&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;"difference between dp at number 1 and rp at value at next number".&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you want the rp test value minus the dp test value for each number.&amp;nbsp; If so, then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge  have (where=(tst='dp') rename=test_rt=dp_test)
         have (where=(tst='rp') rename=test_rt=rp_test);
  by number;
  rp_minus_dp=rp_test-dp_test;
  drop tst ;
  if last.number;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that's not what you mean, please show what the results would look like for the data you provided.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Sep 2021 05:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-of-a-value-from-one-variable-and-the-lead-of-another/m-p/768406#M243732</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-09-18T05:11:14Z</dc:date>
    </item>
  </channel>
</rss>

