<?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: Steped fee calculation in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70209#M20207</link>
    <description>Thank you art297 &lt;BR /&gt;
&lt;BR /&gt;
Another very good approach. I'm going to try this out, I believe one of these solutions should help me resolve my query.&lt;BR /&gt;
&lt;BR /&gt;
Much appreciated.</description>
    <pubDate>Wed, 08 Sep 2010 08:30:14 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-09-08T08:30:14Z</dc:date>
    <item>
      <title>Steped fee calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70205#M20203</link>
      <description>Hi SAS experts,&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to design a loop or a macro that will help me calculate transaction-based fees that are applied in a 'stepped' manner. &lt;BR /&gt;
&lt;BR /&gt;
Example;&lt;BR /&gt;
&lt;BR /&gt;
00001-10000 transactions - 0.25c per transaction&lt;BR /&gt;
10001-25000 transactions - 0.21c per transaction&lt;BR /&gt;
25001-50000 transactions - 0.20c per transaction&lt;BR /&gt;
50001 and above - 0.18c per transaction&lt;BR /&gt;
&lt;BR /&gt;
If 78,000 transactions were processed this month, charge would be,&lt;BR /&gt;
&lt;BR /&gt;
10,000 x 0.25 = 2,500&lt;BR /&gt;
15,000 x 0.21 = 3,150&lt;BR /&gt;
25,000 x 0.20 = 5,000&lt;BR /&gt;
28,000 x 0.18 = 5,040&lt;BR /&gt;
&lt;BR /&gt;
Total charges for 78,000 transactions = 15,690&lt;BR /&gt;
&lt;BR /&gt;
My data set looks something like this;&lt;BR /&gt;
&lt;BR /&gt;
Date...........type............transactions&lt;BR /&gt;
&lt;BR /&gt;
Jan-10........MC..............78,000&lt;BR /&gt;
Feb-10........MC..............72,987&lt;BR /&gt;
Mar-10........MC..............81,214&lt;BR /&gt;
Apr-10.........MC.............79,914&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to transalate this calculation into a sas code/macro. I have many transaction types with their own unique stepped fee rates that I need to apply to the relevant transaction volumes. The stepped fees are available to me in a separate dataset that I can join. Or if its easier I can hard-code the fee bands into the code/macro.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for any help you can offer.</description>
      <pubDate>Mon, 06 Sep 2010 13:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70205#M20203</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-06T13:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Steped fee calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70206#M20204</link>
      <description>1. Create a dataset containing the charge-transaction-relationship:&lt;BR /&gt;
[pre]data work.fee;&lt;BR /&gt;
    input min max charge;&lt;BR /&gt;
    datalines;&lt;BR /&gt;
1 10000 0.25&lt;BR /&gt;
10001 25000 0.21&lt;BR /&gt;
25001 50000 0.2&lt;BR /&gt;
50001 . 0.18&lt;BR /&gt;
;&lt;BR /&gt;
run;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
2. Combine the transaction dataset with the fee dataset:&lt;BR /&gt;
[pre]data work.charged;&lt;BR /&gt;
    set work.transactions;&lt;BR /&gt;
&lt;BR /&gt;
    length total  helper 8;&lt;BR /&gt;
    retain total helper;&lt;BR /&gt;
    drop helper min max charge;&lt;BR /&gt;
&lt;BR /&gt;
    total = 0;&lt;BR /&gt;
    helper = 0;&lt;BR /&gt;
&lt;BR /&gt;
    do i = 1 to 4;&lt;BR /&gt;
        set work.fee point=i;&lt;BR /&gt;
&lt;BR /&gt;
            if transaction &amp;gt; min then do;&lt;BR /&gt;
                if not missing(max) then do;&lt;BR /&gt;
                    total = (max - helper) * charge + total;&lt;BR /&gt;
                    helper = max;&lt;BR /&gt;
                end;&lt;BR /&gt;
                else do;&lt;BR /&gt;
                    total = (transaction - helper) * charge + total;&lt;BR /&gt;
                end;&lt;BR /&gt;
            end;&lt;BR /&gt;
        end;&lt;BR /&gt;
run;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Still to do: create a macro containing the calculating data-step, with parameters for the three datasets involved.</description>
      <pubDate>Mon, 06 Sep 2010 15:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70206#M20204</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2010-09-06T15:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Steped fee calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70207#M20205</link>
      <description>You could turn the following into a macro, but I think that you can do what you want in just a couple of if then statements.  For example:&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
  informat Date monyy6.;&lt;BR /&gt;
  format Date date9.;&lt;BR /&gt;
  informat transactions comma10.;&lt;BR /&gt;
  input Date type $ transactions;&lt;BR /&gt;
  cards;&lt;BR /&gt;
Jan-10 MC 78,000&lt;BR /&gt;
Feb-10 MC 72,987&lt;BR /&gt;
Mar-10 MC 81,214&lt;BR /&gt;
Apr-10 MC 79,914&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data want (drop=hold_transactions);&lt;BR /&gt;
  set have;&lt;BR /&gt;
  cost=0;&lt;BR /&gt;
  hold_transactions=transactions;&lt;BR /&gt;
  if hold_transactions gt 50000 then do;&lt;BR /&gt;
    cost=(hold_transactions-50000)*.18;&lt;BR /&gt;
    hold_transactions=50000;&lt;BR /&gt;
  end;&lt;BR /&gt;
  if hold_transactions gt 25000 then do;&lt;BR /&gt;
    cost=(hold_transactions-25000)*.20+cost;&lt;BR /&gt;
    hold_transactions=25000;&lt;BR /&gt;
  end;&lt;BR /&gt;
  if hold_transactions gt 10000 then do;&lt;BR /&gt;
    cost=(hold_transactions-10000)*.21+cost;&lt;BR /&gt;
    hold_transactions=10000;&lt;BR /&gt;
  end;&lt;BR /&gt;
  cost=hold_transactions*.25+cost;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art</description>
      <pubDate>Mon, 06 Sep 2010 17:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70207#M20205</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-09-06T17:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Steped fee calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70208#M20206</link>
      <description>Thank you andreas_lds  &lt;BR /&gt;
 &lt;BR /&gt;
This looks like a good start to me. i already have a separate dataset with the bandings and the rates, so will adapt your code and see how it works.&lt;BR /&gt;
&lt;BR /&gt;
Appreciate your help.</description>
      <pubDate>Wed, 08 Sep 2010 08:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70208#M20206</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-08T08:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Steped fee calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70209#M20207</link>
      <description>Thank you art297 &lt;BR /&gt;
&lt;BR /&gt;
Another very good approach. I'm going to try this out, I believe one of these solutions should help me resolve my query.&lt;BR /&gt;
&lt;BR /&gt;
Much appreciated.</description>
      <pubDate>Wed, 08 Sep 2010 08:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70209#M20207</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-08T08:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Steped fee calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70210#M20208</link>
      <description>Art, I'm using your approach, its brilliant for what I want now, while im still designing my model, gives me more control over tweaking the bands etc.&lt;BR /&gt;
&lt;BR /&gt;
Andreas, I wll eventually use the loop, although for now I'm hard-coding the rates as number of bands vary by transation type so I cant restrict the loop to 4 iterations. &lt;BR /&gt;
&lt;BR /&gt;
Thanks again for both solutions, very educational.</description>
      <pubDate>Wed, 08 Sep 2010 09:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Steped-fee-calculation/m-p/70210#M20208</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-08T09:43:05Z</dc:date>
    </item>
  </channel>
</rss>

