<?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: I need help with taking the actual count for sales in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862834#M340822</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440474"&gt;@Newbie_23&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello,&lt;BR /&gt;Sorry i did not state the conditions.&lt;BR /&gt;The highest Seq_No number for the same Sales_ID - If Status is set to paid then take the count as count shown under Units_sales ( maybe add additional column as "actual units sold" and show the count) else If status is rejected or reversed, then the actual units sold should be shown as zero.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And what if the number in Rejected or Reversed is not the same as for Paid? Hypothetical&lt;/P&gt;
&lt;PRE&gt;212	0	Paid	  2	2/5/2023	5
212	1	Reversed  2	2/5/2023	1&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you should show what you expect the resulting output should show. Show, NOT describe. Does the date need to be included? The sequence number?&lt;/P&gt;</description>
    <pubDate>Tue, 07 Mar 2023 22:14:24 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-03-07T22:14:24Z</dc:date>
    <item>
      <title>I need help with taking the actual count for sales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862741#M340781</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a table as shown below, the customer_ID is unique, and each sale ID is associated with the customer_ID. Based on the sale ID for each customer , i need to look at the highest seq_no for each Sale_ID and account for the units actually sold based on the status for the last highest sequence number for each sales_ID.&amp;nbsp; For example for customer_ID "1", there was a sale done on 1/1/23 all mapping to Sales_ID "123", but when looking at the status, the actual units sold based on the highest Seq_no and status&amp;nbsp; set to "Paid", the actual units sold were 3.&lt;/P&gt;&lt;P&gt;I need to code this logic , please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the last seq_no for the sales_ID is paid, then count the value, else if rejected or reversed, then it is counted as zero units.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Sales_ID&lt;/TD&gt;&lt;TD&gt;Seq_No&lt;/TD&gt;&lt;TD&gt;Status&lt;/TD&gt;&lt;TD&gt;Customer_ID&lt;/TD&gt;&lt;TD&gt;Sale_ date&lt;/TD&gt;&lt;TD&gt;Units_sales&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;Paid&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1/1/2023&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Rejected&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1/1/2023&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Paid&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1/1/2023&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;155&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;Paid&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2/1/2023&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;212&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;Paid&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2/5/2023&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;212&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Reversed&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2/5/2023&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;215&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;Rejected&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2/5/2023&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 07 Mar 2023 17:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862741#M340781</guid>
      <dc:creator>Newbie_23</dc:creator>
      <dc:date>2023-03-07T17:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with taking the actual count for sales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862761#M340790</link>
      <description>&lt;P&gt;Hint: Show an expected result for example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best is to provide example data as working data step code, barring that open a text window using the &amp;lt;/&amp;gt; and paste plain text of the values. Some of the software that pastes tables are next to impossible to work with.&lt;/P&gt;
&lt;P&gt;Working data step for your example looks like this:&lt;/P&gt;
&lt;PRE&gt;data have;
   input Sales_ID $	Seq_No	Status $	Customer_ID $	Sale_date :mmddyy10.	Units_sales;
   format sale_date mmddyy10.;
datalines;
123	0	Paid	1	1/1/2023	2
123	1	Rejected	1	1/1/2023	2
123	2	Paid	1	1/1/2023	3
155	0	Paid	1	2/1/2023	5
212	0	Paid	2	2/5/2023	1
212	1	Reversed	2	2/5/2023	1
215	0	Rejected	3	2/5/2023	5
;
&lt;/PRE&gt;
&lt;P&gt;One of the reasons we suggest you provide code is that we have to make guesses about displayed values that may not work with your actual data. For example, I assume ID values are character as you seldom do things like "add customer id numbers". I assumed that the date value is in month day year order because it is not possible to tell which is month or day from the example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect you are missing some rules, such as what impact the Rejected or Reversed status has your "count".&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 18:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862761#M340790</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-07T18:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with taking the actual count for sales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862779#M340800</link>
      <description>Hello,&lt;BR /&gt;Your datatype assumption is correct. Only the status set to paid should be accounted for the count. If status set to rejected or reversed then the count is zero</description>
      <pubDate>Tue, 07 Mar 2023 20:12:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862779#M340800</guid>
      <dc:creator>Newbie_23</dc:creator>
      <dc:date>2023-03-07T20:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with taking the actual count for sales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862818#M340817</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440474"&gt;@Newbie_23&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello,&lt;BR /&gt;Your datatype assumption is correct. Only the status set to paid should be accounted for the count. If status set to rejected or reversed then the count is zero&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think this is another case of the user knowing a whole lot more than we do and is not quite able to state the conditions because it is obvious. I asked about showing a result because you have this data:&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;212&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;Paid&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2/5/2023&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;212&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;Reversed&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2/5/2023&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;What is the actual "count" resulting here?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 21:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862818#M340817</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-07T21:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with taking the actual count for sales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862825#M340820</link>
      <description>Hello,&lt;BR /&gt;Sorry i did not state the conditions.&lt;BR /&gt;The highest Seq_No number for the same Sales_ID - If Status is set to paid then take the count as count shown under Units_sales ( maybe add additional column as "actual units sold" and show the count) else If status is rejected or reversed, then the actual units sold should be shown as zero.</description>
      <pubDate>Tue, 07 Mar 2023 21:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862825#M340820</guid>
      <dc:creator>Newbie_23</dc:creator>
      <dc:date>2023-03-07T21:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with taking the actual count for sales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862834#M340822</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440474"&gt;@Newbie_23&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello,&lt;BR /&gt;Sorry i did not state the conditions.&lt;BR /&gt;The highest Seq_No number for the same Sales_ID - If Status is set to paid then take the count as count shown under Units_sales ( maybe add additional column as "actual units sold" and show the count) else If status is rejected or reversed, then the actual units sold should be shown as zero.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And what if the number in Rejected or Reversed is not the same as for Paid? Hypothetical&lt;/P&gt;
&lt;PRE&gt;212	0	Paid	  2	2/5/2023	5
212	1	Reversed  2	2/5/2023	1&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you should show what you expect the resulting output should show. Show, NOT describe. Does the date need to be included? The sequence number?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 22:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862834#M340822</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-07T22:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with taking the actual count for sales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862837#M340823</link>
      <description>For the data that you have questioned,&lt;BR /&gt;212 0 Paid 2 2/5/2023 5&lt;BR /&gt;212 1 Reversed 2 2/5/2023 1&lt;BR /&gt;&lt;BR /&gt;The max seq_no for sale_ID 212 is 1 and the status is set to reversed, in this case the count for the derived column ( actual_units_sold) should be zero</description>
      <pubDate>Tue, 07 Mar 2023 22:27:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-with-taking-the-actual-count-for-sales/m-p/862837#M340823</guid>
      <dc:creator>Newbie_23</dc:creator>
      <dc:date>2023-03-07T22:27:39Z</dc:date>
    </item>
  </channel>
</rss>

