<?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: how to calculate the difference for row data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147559#M297472</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 328px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" width="64"&gt;ID&lt;/TD&gt;&lt;TD class="xl65" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="64"&gt;Type&lt;/TD&gt;&lt;TD class="xl65" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="96"&gt;date&lt;/TD&gt;&lt;TD class="xl65" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="104"&gt;amount&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;878&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;3/12/1999&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;983&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;3/2/1987&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;999&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;31/3/1990&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV data-linkedid="inbox_all_2_203152_14_2007"&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV data-current="true" data-objectid="203258" data-objecttype="2"&gt;1001&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;10000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1001&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;2&lt;/TD&gt;&lt;TD class="xl67" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;10000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1001&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1002&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/31/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;15000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1002&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;2&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/31/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;15000&lt;/TD&gt; &lt;/TR&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; &lt;DIV data-current="true" data-objectid="203258" data-objecttype="2"&gt;&lt;BR /&gt; &lt;/DIV&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1002&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1003&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="22" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1003&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;2&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="20" style="border-color: currentColor black black currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;2001&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;3001&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;0&lt;/TD&gt; &lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to get output only ID records which has type 1,2, and&amp;nbsp; with calculation row like below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="295"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-color: currentColor black black;" width="80"&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV data-linkedid="inbox_all_2_203152_14_2007"&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV data-current="true" data-objectid="203258" data-objecttype="2"&gt;1001&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-left-width: medium; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-left-width: medium; border-left-style: none;" width="87"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-left-width: medium; border-left-style: none;" width="64"&gt;10000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl65" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="80"&gt;1001&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;2&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="87"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;10000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl65" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="80"&gt;1001&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="87"&gt; &lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl65" height="22" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="80"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="87"&gt;4/31/2014&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;15000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl65" height="20" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="80"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;2&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="87"&gt;4/31/2014&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;15000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl65" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="80"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl65" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="87"&gt; &lt;/TD&gt;&lt;TD class="xl65" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;0&lt;/TD&gt; &lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried with this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data out;&lt;/P&gt;&lt;P&gt;set source;&lt;/P&gt;&lt;P&gt;by id;&lt;/P&gt;&lt;P&gt;if first.id eq last.id then outout;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is not working and giving wrong output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can you please guide me how to get the required output?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Apr 2014 13:19:15 GMT</pubDate>
    <dc:creator>Ram4sas</dc:creator>
    <dc:date>2014-04-25T13:19:15Z</dc:date>
    <item>
      <title>how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147550#M297463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have below&amp;nbsp; table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 455px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl71" height="20" width="63"&gt;Cust_No&lt;/TD&gt;&lt;TD class="xl72" style="border-left: none;" width="79"&gt;Cust_cntry&lt;/TD&gt;&lt;TD class="xl72" style="border-left: none;" width="79"&gt;Date&lt;/TD&gt;&lt;TD class="xl72" style="border-left: none;" width="87"&gt;total amount&lt;/TD&gt;&lt;TD class="xl72" style="border-left: none;" width="83"&gt;old balance&lt;/TD&gt;&lt;TD class="xl74" style="border-left: none;" width="64"&gt;banalce&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl67" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;IN&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;4/30/2012&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;10,000.00&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;8000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl67" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;IN&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;4/30/2012&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;10,000.00&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;8000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl67" height="20" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;UK&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;4/31/2012&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;15,000.00&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;3,000.00&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;12000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl68" height="21" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl69" style="border-top: none; border-left: none;"&gt;UK&lt;/TD&gt;&lt;TD class="xl69" style="border-top: none; border-left: none;"&gt;4/31/2012&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top: none; border-left: none;"&gt;15,000.00&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top: none; border-left: none;"&gt;3,000.00&lt;/TD&gt;&lt;TD align="right" class="xl75" style="border-top: none; border-left: none;"&gt;12000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But i want develop this output. how to get this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 455px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl69" height="20" width="63"&gt;Cust_No&lt;/TD&gt;&lt;TD class="xl70" style="border-left: none;" width="79"&gt;Cust_cntry&lt;/TD&gt;&lt;TD class="xl70" style="border-left: none;" width="79"&gt;Date&lt;/TD&gt;&lt;TD class="xl70" style="border-left: none;" width="87"&gt;total amount&lt;/TD&gt;&lt;TD class="xl70" style="border-left: none;" width="83"&gt;old balance&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl68" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;IN&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;4/30/2012&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;10,000.00&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl77" style="border-top: none; border-left: none;"&gt;8000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl68" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;IN&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;4/30/2012&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;10,000.00&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl77" style="border-top: none; border-left: none;"&gt;8000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD class="xl77" style="border-top: none; border-left: none;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl68" height="20" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;UK&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;4/31/2012&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;15,000.00&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;3,000.00&lt;/TD&gt;&lt;TD align="right" class="xl77" style="border-top: none; border-left: none;"&gt;12000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl68" height="20" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;UK&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;4/31/2012&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;15,000.00&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl77" style="border-top: none; border-left: none;"&gt;13000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl74" height="21" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl75" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl75" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD align="right" class="xl76" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl76" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl78" style="border-top: none; border-left: none;"&gt;-1000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could i request all to suggest how to get this output?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2014 14:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147550#M297463</guid>
      <dc:creator>Ram4sas</dc:creator>
      <dc:date>2014-03-18T14:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147551#M297464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How are you calculating the last row?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it was straight totals Proc Tabulate/Print or Report would work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2014 15:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147551#M297464</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-03-18T15:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147552#M297465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Well, for two values its real simple with first/last and by:&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; attrib Cust_No format=8. Cust_cntry Datetotal format=$10. amount old balance format=8.;&lt;BR /&gt;&amp;nbsp; infile datalines;&lt;BR /&gt;&amp;nbsp; input cust_no cust_cntry $ datetotal $ amount old balance;&lt;BR /&gt;datalines; &lt;BR /&gt;1001 IN 4/30/2012 10000.00 2000.00 8000 &lt;BR /&gt;1001 IN 4/30/2012 10000.00 2000.00 8000 &lt;BR /&gt;1002 UK 4/31/2012 15000.00 3000.00 12000 &lt;BR /&gt;1002 UK 4/31/2012 15000.00 2000.00 13000&lt;BR /&gt;;&lt;BR /&gt;run; &lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; by cust_no;&lt;BR /&gt;&amp;nbsp; retain lstamnt lstold lstbal;&lt;BR /&gt;&amp;nbsp; if first.cust_no then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstamnt=amount;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstold=old;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstbal=balance;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; else do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cust_cntry="";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; datetotal="";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; amount=lstamnt-amount;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; old=lstold-old;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; balance=lstbal-balance;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For more rows you just need to have a third if statement to capture not first and not last.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2014 15:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147552#M297465</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-03-18T15:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147553#M297466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about the diff or lag function instead?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2014 15:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147553#M297466</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-03-18T15:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147554#M297467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi RW9,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;its working fine. i want to add one more column in the last as called 'Diff'.based on Balance value value should be equal or Under if negative value.&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="519"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" height="20" width="63"&gt;Cust_No&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="79"&gt;Cust_cntry&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="79"&gt;Date&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="87"&gt;total amount&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="83"&gt;old balance&lt;/TD&gt;&lt;TD class="xl76" style="border-left: none;" width="64"&gt;Balance&lt;/TD&gt;&lt;TD class="xl75" style="border-left: none;" width="64"&gt;Diff&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;IN&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4/30/2014&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;10,000.00&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;8000&lt;/TD&gt;&lt;TD class="xl74" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;IN&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4/30/2014&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;10,000.00&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;8000&lt;/TD&gt;&lt;TD class="xl74" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl68" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl69" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl69" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD class="xl74" style="border-top: none; border-left: none;"&gt;Equal&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;UK&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4/31/2014&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;15,000.00&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;3,000.00&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;12000&lt;/TD&gt;&lt;TD class="xl74" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;UK&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4/31/2014&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;15,000.00&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;13000&lt;/TD&gt;&lt;TD class="xl74" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="21" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl72" style="border-top: none; border-left: none;"&gt;-1000&lt;/TD&gt;&lt;TD class="xl77" style="border-top: none; border-left: none;"&gt;Under&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;IMG alt="Reeza" class="jive-avatar jiveImage" data-avatarid="1002" data-height="32" data-random="0yzvm0409yhr7wrk9" data-username="Reeza" height="32" src="https://communities.sas.com/people/Reeza/avatar/32.png?a=1002" width="32" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2014 16:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147554#M297467</guid>
      <dc:creator>Ram4sas</dc:creator>
      <dc:date>2014-03-18T16:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147555#M297468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just add an if statement in (note untested as no longer at work):&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib diff format=$10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by cust_no;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain lstamnt lstold lstbal;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.cust_no then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstamnt=amount;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstold=old;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstbal=balance;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cust_cntry="";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; datetotal="";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; amount=lstamnt-amount;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; old=lstold-old;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; balance=lstbal-balance;&lt;/P&gt;&lt;P&gt;/****/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if balance &amp;lt; 0 then diff="Under";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if balance=0 then diff="Equal";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else diff="Over";&lt;/P&gt;&lt;P&gt;/****/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2014 17:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147555#M297468</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-03-18T17:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147556#M297469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to add extra column called 'Other' with difference values for that column values.&lt;/P&gt;&lt;P&gt;if data values available then it it has to hold the difference between those values as above.&lt;/P&gt;&lt;P&gt;if no data values then the difference should display as 0.00. like below.&amp;nbsp; how to get this output.&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 583px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" height="20" width="63"&gt;Cust_No&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="79"&gt;Cust_cntry&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="79"&gt;Date&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="87"&gt;total amount&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="83"&gt;old balance&lt;/TD&gt;&lt;TD class="xl76" style="border-left: none;" width="64"&gt;Balance&lt;/TD&gt;&lt;TD class="xl77" style="border-left: none;" width="64"&gt;Diff&lt;/TD&gt;&lt;TD class="xl75" width="64"&gt;Other&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;IN&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4/30/2014&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;10,000.00&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;8000&lt;/TD&gt;&lt;TD class="xl78" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl74" style="border-top: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;IN&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4/30/2014&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;10,000.00&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;8000&lt;/TD&gt;&lt;TD class="xl78" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl74" style="border-top: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl68" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl69" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl69" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD class="xl78" style="border-top: none; border-left: none;"&gt;Equal&lt;/TD&gt;&lt;TD align="right" class="xl80" style="border-top: none;"&gt;0.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;UK&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4/31/2014&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;15,000.00&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;3,000.00&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;12000&lt;/TD&gt;&lt;TD class="xl78" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top: none;"&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;UK&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4/31/2014&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;15,000.00&lt;/TD&gt;&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;2,000.00&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;13000&lt;/TD&gt;&lt;TD class="xl78" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top: none;"&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="21" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;0.00&lt;/TD&gt;&lt;TD align="right" class="xl72" style="border-top: none; border-left: none;"&gt;-1000&lt;/TD&gt;&lt;TD class="xl79" style="border-top: none; border-left: none;"&gt;Under&lt;/TD&gt;&lt;TD align="right" class="xl80" style="border-top: none;"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in Advance..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 03:02:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147556#M297469</guid>
      <dc:creator>Ram4sas</dc:creator>
      <dc:date>2014-03-19T03:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147557#M297470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You just need to look at adding if statements as appropriate (marked where I would put them below), logic for that I will leave to you:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib diff format=$10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by cust_no;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain lstamnt lstold lstbal;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Insert your logic to work out that column, e.g. if something &amp;lt; something else then other=something-something else */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if first.cust_no then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstamnt=amount;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstold=old;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstbal=balance;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cust_cntry="";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; datetotal="";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; amount=lstamnt-amount;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; old=lstold-old;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; balance=lstbal-balance;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if balance &amp;lt; 0 then diff="Under";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if balance=0 then diff="Equal";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else diff="Over";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 08:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147557#M297470</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-03-19T08:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147558#M297471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI RW9,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ok, thank you for your quick reply. its really helps me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 11:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147558#M297471</guid>
      <dc:creator>Ram4sas</dc:creator>
      <dc:date>2014-03-19T11:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147559#M297472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 328px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" width="64"&gt;ID&lt;/TD&gt;&lt;TD class="xl65" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="64"&gt;Type&lt;/TD&gt;&lt;TD class="xl65" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="96"&gt;date&lt;/TD&gt;&lt;TD class="xl65" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="104"&gt;amount&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;878&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;3/12/1999&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;983&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;3/2/1987&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;999&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;31/3/1990&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV data-linkedid="inbox_all_2_203152_14_2007"&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV data-current="true" data-objectid="203258" data-objecttype="2"&gt;1001&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;10000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1001&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;2&lt;/TD&gt;&lt;TD class="xl67" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;10000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1001&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1002&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/31/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;15000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1002&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;2&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/31/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;15000&lt;/TD&gt; &lt;/TR&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; &lt;DIV data-current="true" data-objectid="203258" data-objecttype="2"&gt;&lt;BR /&gt; &lt;/DIV&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1002&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1003&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="22" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="64"&gt;1003&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;2&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="20" style="border-color: currentColor black black currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;2001&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl66" height="19" style="border-color: currentColor black black currentColor; border-top-width: medium; border-top-style: none;" width="64"&gt;3001&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="96"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl66" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="104"&gt;0&lt;/TD&gt; &lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to get output only ID records which has type 1,2, and&amp;nbsp; with calculation row like below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="295"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-color: currentColor black black;" width="80"&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV data-linkedid="inbox_all_2_203152_14_2007"&gt;&lt;BR /&gt;&amp;nbsp; &lt;DIV data-current="true" data-objectid="203258" data-objecttype="2"&gt;1001&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-left-width: medium; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-left-width: medium; border-left-style: none;" width="87"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-left-width: medium; border-left-style: none;" width="64"&gt;10000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl65" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="80"&gt;1001&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;2&lt;/TD&gt;&lt;TD class="xl66" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="87"&gt;4/30/2014&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;10000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl65" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="80"&gt;1001&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="87"&gt; &lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl65" height="22" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="80"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="87"&gt;4/31/2014&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;15000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl65" height="20" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="80"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;2&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="87"&gt;4/31/2014&lt;/TD&gt;&lt;TD class="xl65" style="border-color: currentColor black black currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;15000&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt;&lt;TD class="xl65" height="19" style="border-color: currentColor black black; border-top-width: medium; border-top-style: none;" width="80"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl65" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="87"&gt; &lt;/TD&gt;&lt;TD class="xl65" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;" width="64"&gt;0&lt;/TD&gt; &lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried with this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data out;&lt;/P&gt;&lt;P&gt;set source;&lt;/P&gt;&lt;P&gt;by id;&lt;/P&gt;&lt;P&gt;if first.id eq last.id then outout;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is not working and giving wrong output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can you please guide me how to get the required output?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Apr 2014 13:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147559#M297472</guid>
      <dc:creator>Ram4sas</dc:creator>
      <dc:date>2014-04-25T13:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147560#M297473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure, if that is the question, but you could do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data out;&lt;/P&gt;&lt;P&gt;set source;&lt;/P&gt;&lt;P&gt;where(type in (.,1,2));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"." does specify the so called missing values you seem to have in your calculation row and the rest should be quite self-eplanatory &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>Fri, 25 Apr 2014 13:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147560#M297473</guid>
      <dc:creator>mfab</dc:creator>
      <dc:date>2014-04-25T13:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the difference for row data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147561#M297474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;first. only marks that you are reading the first record of a by group, last. does the same for the last record.&lt;/P&gt;&lt;P&gt;Your condition will therefore be true if the by group only has one record (wich is the first and last at the same time) or for records that are neither first or last of their respective by group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you probably want is to compare a value from the first record with that of the last. You willl need to RETAIN a variable:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want1 (keep=id);&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by id;&lt;/P&gt;&lt;P&gt;retain int_amount;&lt;/P&gt;&lt;P&gt;if first.id then int_amount=amount;&lt;/P&gt;&lt;P&gt;if last.id and amount = in_amount then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you have a table of id's that represent those by groups where the amount in the last record is equal to the amount in the first record. When you merge that back with the original data set and keep only matching records, you get your wanted by groups.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Apr 2014 13:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-difference-for-row-data/m-p/147561#M297474</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-04-25T13:30:11Z</dc:date>
    </item>
  </channel>
</rss>

