<?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: something wrong with my coding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663992#M198319</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/334109"&gt;@IdlanHnf&lt;/a&gt;&amp;nbsp;Since this discussion is closed ("Solved"), if you have a follow-up question, it would be best to post it as a new discussion (including your question, your code, etc.). You'll get a lot more people viewing it then.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jun 2020 14:18:22 GMT</pubDate>
    <dc:creator>mklangley</dc:creator>
    <dc:date>2020-06-22T14:18:22Z</dc:date>
    <item>
      <title>something wrong with my coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663296#M197966</link>
      <description>&lt;P&gt;so here's is my coding. from my data the first totalprice*unit =70MYR. when I run it, the discount I get is 4.90MYR. If is calculate it manually, the discount that I should get is 3.50MYR. Does anyone know how to do it correctly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA Payment;&lt;BR /&gt;SET combined;&lt;BR /&gt;LENGTH total $ 10;&lt;BR /&gt;LABEL 	total='Total Price (RM)'&lt;BR /&gt;		after='Total Price after Discount (RM)'&lt;BR /&gt;		dis='Discount (RM)'&lt;BR /&gt;		fee='Courier Fee (RM)'&lt;BR /&gt;		net='Net Amount (RM)';&lt;BR /&gt;total='Price (RM)'n*unit;&lt;BR /&gt;	IF 		total&amp;gt;=20 THEN after=total-dis;&lt;BR /&gt;	ELSE 	dis=total*0.05;&lt;BR /&gt;	IF 		total&amp;gt;=30 THEN dis=total*0.07;&lt;BR /&gt;	ELSE 	dis=total*0.00;&lt;BR /&gt;after=total-dis;&lt;BR /&gt;net=after+5;&lt;BR /&gt;RUN;&lt;BR /&gt;PROC PRINT DATA=Payment label;&lt;BR /&gt;	TITLE 'Monarch Online Shop';&lt;BR /&gt;	FOOTNOTE 'STAY AT HOME AND STAY SAFE';&lt;BR /&gt;RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 19:48:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663296#M197966</guid>
      <dc:creator>IdlanHnf</dc:creator>
      <dc:date>2020-06-18T19:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: something wrong with my coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663303#M197971</link>
      <description>&lt;P&gt;Think through your conditional statements using 70MYR. Are they what you intend?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;From your logic, total = 70 goes into the first IF statement (since 70 is &amp;gt;= 20), so AFTER is set to total-dis.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;And total =70 also goes into the second IF statement (since 70 is &amp;gt;= 30), so DIS is set to 70 * 0.07.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;So from your logic,&amp;nbsp;4.90MYR is the correct result.&amp;nbsp;&lt;/SPAN&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is DIS = TOTAL * 0.05 supposed to be applied when Total is &amp;gt;= 20? Right now, since you have that in an ELSE statement, it won't be applied.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 20:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663303#M197971</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-06-18T20:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: something wrong with my coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663307#M197973</link>
      <description>&lt;P&gt;Look closely here:&lt;/P&gt;
&lt;PRE&gt;	IF 		total&amp;gt;=20 THEN&lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt; after=total-dis;&lt;/FONT&gt;&lt;/STRONG&gt;
	ELSE 	dis=total*0.05;
	IF 		total&amp;gt;=30 THEN dis=total*0.07;
	ELSE 	dis=total*0.00;
&lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;after=total-dis;&lt;/FONT&gt;&lt;/STRONG&gt;
net=after+5;&lt;/PRE&gt;
&lt;P&gt;So when you have Total&amp;gt;= 20 you calculate After twice with different values of dis. So, which one do you expect? Also the first time you use total-dis the value of dis is not set, so that After is missing as a result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also need to consider that every value &amp;gt;30 is also greater than 20. Perhaps sequence of calculation is not as you do manually. Computers don't know to stop unless you tell them to explicitly.&lt;/P&gt;
&lt;P&gt;I suggest that every where you have a "dis =" to create a different variable: dis1 = &amp;lt;calculation&amp;gt;; dis2= &amp;lt;calculation&amp;gt; . Then look at the different values and see what is going on.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 20:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663307#M197973</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-18T20:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: something wrong with my coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663309#M197975</link>
      <description>&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Buyer that spent more than RM20 (excluding courier fee) will receive 5% discount, and buyer that spent more than RM30 (excluding courier fee) will receive 7% discount. Using SAS, calculate the net amount that the buyer needs to pay for that order (cost of item + courier fee). This is the question I got.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;How can I make that if total=70, it only use either one of the statement?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 20:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663309#M197975</guid>
      <dc:creator>IdlanHnf</dc:creator>
      <dc:date>2020-06-18T20:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: something wrong with my coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663311#M197976</link>
      <description>Your criteria is not mutually exclusive which is weird. If your total is greater than 30, it passes both criteria.&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Jun 2020 20:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663311#M197976</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-18T20:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: something wrong with my coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663312#M197977</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/334109"&gt;@IdlanHnf&lt;/a&gt;&amp;nbsp;Try this:&lt;/P&gt;
&lt;PRE&gt;IF total&amp;gt;=30&lt;BR /&gt;    THEN dis=total*0.07;&lt;BR /&gt;ELSE IF total&amp;gt;=20 &lt;BR /&gt;    THEN dis=total*0.05;&lt;BR /&gt;ELSE dis=total*0.00;&lt;BR /&gt;&lt;BR /&gt;after = total-dis;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 20:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663312#M197977</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-06-18T20:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: something wrong with my coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663314#M197978</link>
      <description>&lt;P&gt;thank you for your help. I understand now what was my mistake. thanks for enlightening me.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 20:33:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663314#M197978</guid>
      <dc:creator>IdlanHnf</dc:creator>
      <dc:date>2020-06-18T20:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: something wrong with my coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663317#M197980</link>
      <description>&lt;P&gt;as you can see at Label, I put fee='Courier Fee (RM)'. how can I add another line of coding that consist of detail about the fee? for example, I have 2 couriers, PosLaju, and GDex with a different fee, 2MYR, and 3MYR, respectively. and how to add that into a function like this? i want to make it become if my first order is using PosLaju, so for the function below, fee become 2MYR&lt;/P&gt;&lt;PRE&gt;net=after+fee;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 20:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663317#M197980</guid>
      <dc:creator>IdlanHnf</dc:creator>
      <dc:date>2020-06-18T20:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: something wrong with my coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663992#M198319</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/334109"&gt;@IdlanHnf&lt;/a&gt;&amp;nbsp;Since this discussion is closed ("Solved"), if you have a follow-up question, it would be best to post it as a new discussion (including your question, your code, etc.). You'll get a lot more people viewing it then.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 14:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/something-wrong-with-my-coding/m-p/663992#M198319</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-06-22T14:18:22Z</dc:date>
    </item>
  </channel>
</rss>

