<?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: To Subtract the amount from the same column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/To-Subtract-the-amount-from-the-same-column/m-p/255545#M48807</link>
    <description>&lt;P&gt;Not sure about the&amp;nbsp;business rule here. Could it be that certain Sal ID should always be calculated as minus?&lt;/P&gt;
&lt;P&gt;If so, have a lookup table ("dimension") with each Sal ID and with a mult column (1 or -1).&lt;/P&gt;
&lt;P&gt;Join back with your transaction data multiply&amp;nbsp;with your Amount.&lt;/P&gt;
&lt;P&gt;Then it's not clear how you wish to classify the row with the result, is id Sal ID 3600, or perhaps it should be assigned a new id, since it has been transformed...&lt;/P&gt;
&lt;P&gt;Again, this&amp;nbsp;can be handled in a lookup/dimension table.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Mar 2016 15:05:04 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2016-03-09T15:05:04Z</dc:date>
    <item>
      <title>To Subtract the amount from the same column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-Subtract-the-amount-from-the-same-column/m-p/255536#M48804</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My file contains the below data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Employee Id Sal ID &amp;nbsp; &amp;nbsp;Amount&lt;/STRONG&gt;&lt;BR /&gt;27000002 &amp;nbsp; &amp;nbsp; &amp;nbsp;1900 &amp;nbsp; &amp;nbsp; &amp;nbsp;0.00&lt;BR /&gt;27000002 &amp;nbsp; &amp;nbsp; &amp;nbsp;2100 &amp;nbsp; &amp;nbsp; &amp;nbsp;78.00&lt;BR /&gt;27000002 &amp;nbsp; &amp;nbsp; &amp;nbsp;3600 &amp;nbsp; &amp;nbsp; &amp;nbsp;100.00&lt;BR /&gt;27000002 &amp;nbsp; &amp;nbsp; &amp;nbsp;7500 &amp;nbsp; &amp;nbsp; &amp;nbsp;110.00&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I need to calculate the amount for the&amp;nbsp;&lt;STRONG&gt;Sal ID 3600 = 3600(100.00) - 2100(78.00)&amp;nbsp;&lt;/STRONG&gt;and rest all the Sal ID amounts needs to be reported as it in the file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure , how to subtract the value from the same column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please share your thoughts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!..&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 14:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-Subtract-the-amount-from-the-same-column/m-p/255536#M48804</guid>
      <dc:creator>AshokD</dc:creator>
      <dc:date>2016-03-09T14:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: To Subtract the amount from the same column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-Subtract-the-amount-from-the-same-column/m-p/255545#M48807</link>
      <description>&lt;P&gt;Not sure about the&amp;nbsp;business rule here. Could it be that certain Sal ID should always be calculated as minus?&lt;/P&gt;
&lt;P&gt;If so, have a lookup table ("dimension") with each Sal ID and with a mult column (1 or -1).&lt;/P&gt;
&lt;P&gt;Join back with your transaction data multiply&amp;nbsp;with your Amount.&lt;/P&gt;
&lt;P&gt;Then it's not clear how you wish to classify the row with the result, is id Sal ID 3600, or perhaps it should be assigned a new id, since it has been transformed...&lt;/P&gt;
&lt;P&gt;Again, this&amp;nbsp;can be handled in a lookup/dimension table.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 15:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-Subtract-the-amount-from-the-same-column/m-p/255545#M48807</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-03-09T15:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: To Subtract the amount from the same column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-Subtract-the-amount-from-the-same-column/m-p/255549#M48810</link>
      <description>&lt;P&gt;Could you clarify a bit. &amp;nbsp;Why is 3600 chosen as the start, is it becaue it is 100%? &amp;nbsp;Does everything from that point on need to taken of the sal id? &amp;nbsp;If so then a reverse sort would be best:&lt;/P&gt;
&lt;P&gt;proc sort data=have;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; by employee_id descending sa_id;&lt;/P&gt;
&lt;P&gt;run;&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; retain result;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; by employee_id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if first.employee_id then result=.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if amount=100 then result=sal_id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; else if result ne . then result=result - sal_id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, posting test data in a datastep, i.e. on we can copy and paste directly is more likely to get you tested code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 15:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-Subtract-the-amount-from-the-same-column/m-p/255549#M48810</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-09T15:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: To Subtract the amount from the same column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-Subtract-the-amount-from-the-same-column/m-p/255562#M48816</link>
      <description>&lt;P&gt;Also, look at LAG functions, but note that they don't work in IF statements.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 15:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-Subtract-the-amount-from-the-same-column/m-p/255562#M48816</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-09T15:51:17Z</dc:date>
    </item>
  </channel>
</rss>

