<?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: If statement to calculate price based on count in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506569#M1353</link>
    <description>So that worked! However, now my only problem is that the price for all of the other products are showing up as .73 cents when they arent that price. I appreciate all your help with this.</description>
    <pubDate>Mon, 22 Oct 2018 18:55:23 GMT</pubDate>
    <dc:creator>aperansi</dc:creator>
    <dc:date>2018-10-22T18:55:23Z</dc:date>
    <item>
      <title>If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506518#M1341</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the data set below in which I am trying to set a different price based on the count column. For the product Bank Account Verify, anytime the count goes over 25k, I need the program to input the price of .63 cents. My If statement below does that, however I still have an issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The way the product works is we are billed for the first 25k at one rate. Anything over 25k, we are then billed at a smaller rate. I want the program to still have a price of .73 cents for the first 25k count, and anything over that will be priced at the .63 cent rate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final result should show two different observations on the data set with the two different prices based on the counts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please provide any recommendations you have, and thank you for taking the time to assist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 20:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506518#M1341</guid>
      <dc:creator>aperansi</dc:creator>
      <dc:date>2018-11-27T20:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506528#M1342</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Ryan.MicroBiltDiscount; 
set Vendor_Final_Price;&lt;BR /&gt;Price = .73; 
if Count &amp;gt; 25000 and product = 'Bank Account Verify' then do;&lt;BR /&gt;	Price = .63;&lt;BR /&gt;	Count = Count-25000;&lt;BR /&gt;	output;&lt;BR /&gt;	Price = .73;&lt;BR /&gt;	Count =25000;&lt;BR /&gt;	output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Try this out and let me know&amp;nbsp;if it works. If It does, I can explain some of the rationale behind it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 16:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506528#M1342</guid>
      <dc:creator>ewv</dc:creator>
      <dc:date>2018-10-22T16:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506530#M1343</link>
      <description>&lt;P&gt;&amp;nbsp;INPUT and desired OUTPUT for given input help. It isn't quite clear what "The final result should show two different observations on the data set with the two different prices based on the counts." actually means in this context. Show some output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you say: ". My If statement below does that, however I still have an issue". So, What is the issue? Incorrect value on some records, all records,&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 16:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506530#M1343</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-22T16:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506531#M1344</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data subset;
set yourdata;
where count &amp;gt; 25000;
run;

proc sort data = subset;
by count;
run;

data subset;
if first.count then price = 0.73;
else price = 0.63;
run;

data subset1;
set yourdata;
where count &amp;lt;= 25000;
run;

proc sort data = subset1;
by count;
run;

proc append base = subset1 data = subset;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Oct 2018 16:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506531#M1344</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-10-22T16:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506536#M1345</link>
      <description>&lt;P&gt;With the code I have, I cant show you what I want the output I want looks like, but I made an example in Excel for you to see.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The total count for the Bank Account Verify Product in the month of September is 62,309.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first observation has a count of 25k, and the price is .73 cents. The next observations count has whats left of the total count for the Bank Account Verify product, and It has a price of .63 cents. Hope this makes sense.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, the issue I am having is with the current if statement.&amp;nbsp;&amp;nbsp;It is assigning the price of .63 cents to the Bank Account Verify product when the count is over 25k. I need it to break out the first 25k at .73 cents, then the remaining of the count at .63 cents.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;vendor&lt;/TD&gt;&lt;TD&gt;mid&lt;/TD&gt;&lt;TD&gt;product&lt;/TD&gt;&lt;TD&gt;Count&lt;/TD&gt;&lt;TD&gt;Price&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;2018-09&lt;/TD&gt;&lt;TD&gt;MicroBilt&lt;/TD&gt;&lt;TD&gt;Online&lt;/TD&gt;&lt;TD&gt;Bank Account Verify&lt;/TD&gt;&lt;TD&gt;25,000&lt;/TD&gt;&lt;TD&gt;0.73&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2018-09&lt;/TD&gt;&lt;TD&gt;MicroBilt&lt;/TD&gt;&lt;TD&gt;Online&lt;/TD&gt;&lt;TD&gt;Bank Account Verify&lt;/TD&gt;&lt;TD&gt;37,309&lt;/TD&gt;&lt;TD&gt;0.63&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 22 Oct 2018 17:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506536#M1345</guid>
      <dc:creator>aperansi</dc:creator>
      <dc:date>2018-10-22T17:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506538#M1346</link>
      <description>This did work! The only problem now is that the rest of the products that I have coming into the MICROBILTDISCOUNT data set didnt pull in. The other products dont need this discount applied, but I just wanted them all to pull in to make it easier for the next datastep.</description>
      <pubDate>Mon, 22 Oct 2018 17:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506538#M1346</guid>
      <dc:creator>aperansi</dc:creator>
      <dc:date>2018-10-22T17:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506553#M1348</link>
      <description>data Ryan.MicroBiltDiscount; set Vendor_Final_Price;&lt;BR /&gt;Price = .73; if Count &amp;gt; 25000 and product = 'Bank Account Verify' then do;&lt;BR /&gt;Price = .63;&lt;BR /&gt;Count = Count-25000;&lt;BR /&gt;output;&lt;BR /&gt;Price = .73;&lt;BR /&gt;Count =25000;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;else output;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I added the line 'else output;' on the second to last line. Let me know if that solves it</description>
      <pubDate>Mon, 22 Oct 2018 18:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506553#M1348</guid>
      <dc:creator>ewv</dc:creator>
      <dc:date>2018-10-22T18:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506569#M1353</link>
      <description>So that worked! However, now my only problem is that the price for all of the other products are showing up as .73 cents when they arent that price. I appreciate all your help with this.</description>
      <pubDate>Mon, 22 Oct 2018 18:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506569#M1353</guid>
      <dc:creator>aperansi</dc:creator>
      <dc:date>2018-10-22T18:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506571#M1354</link>
      <description>Is price also a variable from the Vendor_Final_price table? If so, I think you could just remove the first instance of 'Price = .73;' outside of if statements.</description>
      <pubDate>Mon, 22 Oct 2018 18:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506571#M1354</guid>
      <dc:creator>ewv</dc:creator>
      <dc:date>2018-10-22T18:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506573#M1355</link>
      <description>Glad to help! Been working on my SAS certifications so this is good practice. We'll solve it one piece at a time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 22 Oct 2018 19:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506573#M1355</guid>
      <dc:creator>ewv</dc:creator>
      <dc:date>2018-10-22T19:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506574#M1356</link>
      <description>Yeah, its a variable in the Vendor_Final_Price table. I tried that and it worked! Thank you again!&lt;BR /&gt;&lt;BR /&gt;Would you mind explaining the rationale behind the code so that I have an understanding to apply this later down the line?</description>
      <pubDate>Mon, 22 Oct 2018 19:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506574#M1356</guid>
      <dc:creator>aperansi</dc:creator>
      <dc:date>2018-10-22T19:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: If statement to calculate price based on count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506586#M1359</link>
      <description>&lt;P&gt;Absolutely. So in a SAS data step program, there is an implicit "OUTPUT" command for each time it loops through the data step&lt;/P&gt;&lt;P&gt;So in your original code...&lt;BR /&gt;data Ryan.MicroBiltDiscount; set Vendor_Final_Price; if Count &amp;gt; 25000 and product = 'Bank Account Verify' then Price = .63; run;&lt;BR /&gt;... each loop through the data set it would evaluate the if condition, change price if the if condition was true, and the OUTPUT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my adjustments...&lt;BR /&gt;data Ryan.MicroBiltDiscount; set Vendor_Final_Price;&lt;BR /&gt;if Count &amp;gt; 25000 and product = 'Bank Account Verify' then do;&lt;BR /&gt;Price = .63;&lt;BR /&gt;Count = Count-25000;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;output&lt;/FONT&gt;;&lt;BR /&gt;Price = .73;&lt;BR /&gt;Count =25000;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;output;&lt;/FONT&gt;&lt;BR /&gt;end;&lt;BR /&gt;else &lt;FONT color="#ff0000"&gt;output&lt;/FONT&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.. I have 3 explicit OUTPUT statements. Each output statement will create a new row in your output data set. So when the if condition is true (Count &amp;gt; 25000 and product = 'Bank Account Verify'&amp;nbsp;) it &lt;EM&gt;outputs &lt;/EM&gt;two rows as required by your needs. However, when the if condition is false, it runs the else statement and outputs only one row, without making any data changes (which is why I had you remove the first instance of "price = .73;" because that wasn't in the IF statement and was always going to be run even when you didn't want to change the price.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I mentioned in the beginning of this that there is an implicit OUTPUT&amp;nbsp;at the end of&amp;nbsp;a datastep program. &lt;EM&gt;However,&lt;/EM&gt; if you have any explicit OUTPUT statements, it will not include this implicit output. This is why I included the "else output" statement, and why you weren't seeing any of your other product codes with my first code draft.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that help!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 19:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-statement-to-calculate-price-based-on-count/m-p/506586#M1359</guid>
      <dc:creator>ewv</dc:creator>
      <dc:date>2018-10-22T19:32:50Z</dc:date>
    </item>
  </channel>
</rss>

