<?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: calculate discount based on purchase amount in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607593#M176670</link>
    <description>&lt;P&gt;PROC FORMAT is well suited for this kind of classification problem. See if you can use this as a template&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    invalue discount 
        0    -&amp;lt; 1000 = 0
        1000 -&amp;lt; 2000 = 0.05
        2000 -&amp;lt; 3000 = 0.2
        3000 - high = 0.3;
run;

data have;
input cid amt;
datalines;
1 1000
2 2000
3 3000
4 4000
;

data want;
    set have;
    dicount=input(amt, discount.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Nov 2019 09:49:40 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-11-27T09:49:40Z</dc:date>
    <item>
      <title>calculate discount based on purchase amount</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607587#M176667</link>
      <description>&lt;P&gt;I have to calculate the discount based on the purchased amount by the customer. For example if he has purchased for amount&amp;nbsp; 1000 Rs, he should get 5% discount and if he bought for 2000 the discount should be 10% and if he has done for 3000 he should get 20% and above 3000 means he should get 30% discount.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So we have to calculate the&amp;nbsp; amount in the new variable&amp;nbsp; after the discount is applied .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cid&lt;SPAN style="display: inline !important; float: none; background-color: #efefef; color: #000000; font-family: monospace,monospace; font-size: 95%; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.5; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;&amp;nbsp; purchased_amt&lt;BR /&gt;&amp;nbsp;&amp;nbsp;1&amp;nbsp; 1000&lt;BR /&gt;&amp;nbsp;&amp;nbsp;2&amp;nbsp; 2000&lt;BR /&gt;&amp;nbsp;&amp;nbsp;3&amp;nbsp; 3000&lt;BR /&gt;&amp;nbsp;&amp;nbsp;4&amp;nbsp; 4000 &lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 09:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607587#M176667</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2019-11-27T09:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: calculate discount based on purchase amount</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607593#M176670</link>
      <description>&lt;P&gt;PROC FORMAT is well suited for this kind of classification problem. See if you can use this as a template&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    invalue discount 
        0    -&amp;lt; 1000 = 0
        1000 -&amp;lt; 2000 = 0.05
        2000 -&amp;lt; 3000 = 0.2
        3000 - high = 0.3;
run;

data have;
input cid amt;
datalines;
1 1000
2 2000
3 3000
4 4000
;

data want;
    set have;
    dicount=input(amt, discount.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 09:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607593#M176670</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-27T09:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: calculate discount based on purchase amount</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607605#M176672</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/150852"&gt;@rohithverma&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this. Hope this help!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input cid amt;
	cards;
1 1000
2 2000
3 3000
4 4000
;
run;

data want;
    set have;
    format discount percent.;
    if 		   0 &amp;lt; amt &amp;lt;= 1000 then discount = 0;
    else if 1000 &amp;lt; amt &amp;lt;= 2000 then discount = 0.05;
    else if 2000 &amp;lt; amt &amp;lt;= 3000 then discount = 0.2;
    else discount = 0.3;
    new_amt = amt * (1-discount);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Capture d’écran 2019-11-27 à 11.15.47.png" style="width: 277px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34273iA557957F549ABA33/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2019-11-27 à 11.15.47.png" alt="Capture d’écran 2019-11-27 à 11.15.47.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 10:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607605#M176672</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-11-27T10:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: calculate discount based on purchase amount</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607609#M176674</link>
      <description>&lt;P&gt;Thank you very much..!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 10:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607609#M176674</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2019-11-27T10:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: calculate discount based on purchase amount</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607610#M176675</link>
      <description>Thank you very much..!</description>
      <pubDate>Wed, 27 Nov 2019 10:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607610#M176675</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2019-11-27T10:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: calculate discount based on purchase amount</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607769#M176744</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/150852"&gt;@rohithverma&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much..!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One of the &lt;STRONG&gt;very powerful&lt;/STRONG&gt; advantages to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;'s approach is that if the rules change for this discounting procedure you only have to make the change in the proc format code where it would be easy to modify the discount range, the actual discount or both.&lt;/P&gt;
&lt;P&gt;A solution that involves If/then/else coding requires modifying more code with associated increased possibilities of typos or missing an end point for a range.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 16:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-discount-based-on-purchase-amount/m-p/607769#M176744</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-27T16:21:31Z</dc:date>
    </item>
  </channel>
</rss>

