<?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: Top two records by customer/group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Top-two-records-by-customer-group/m-p/358465#M84235</link>
    <description>&lt;P&gt;Hi Mona,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the solution I posted here, is exactly what you need, expect you want to use 2 instead of 4.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Selecting-the-closest-4-propensity-scores-as-controls/td-p/358457" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Selecting-the-closest-4-propensity-scores-as-controls/td-p/358457&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by customerID descending amount;
run;

data want;
set have;
by customerID;

if first.caseID then count=0;
count+1;

if count &amp;lt;= 2;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 13 May 2017 19:22:16 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-05-13T19:22:16Z</dc:date>
    <item>
      <title>Top two records by customer/group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Top-two-records-by-customer-group/m-p/358463#M84233</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am having following dataset with me-:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first column is customerid and second one is spend. Can anyboby explain the logic for calculation top two transactions of each customer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 500&lt;/P&gt;
&lt;P&gt;1 200&lt;/P&gt;
&lt;P&gt;1 100&lt;/P&gt;
&lt;P&gt;2 900&lt;/P&gt;
&lt;P&gt;2 550&lt;/P&gt;
&lt;P&gt;2 200&lt;/P&gt;
&lt;P&gt;3 1900&lt;/P&gt;
&lt;P&gt;3 1300&lt;/P&gt;
&lt;P&gt;3 750&lt;/P&gt;
&lt;P&gt;3 500&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;
&lt;P&gt;Mona&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2017 19:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Top-two-records-by-customer-group/m-p/358463#M84233</guid>
      <dc:creator>Mona1</dc:creator>
      <dc:date>2017-05-13T19:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Top two records by customer/group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Top-two-records-by-customer-group/m-p/358465#M84235</link>
      <description>&lt;P&gt;Hi Mona,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the solution I posted here, is exactly what you need, expect you want to use 2 instead of 4.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Selecting-the-closest-4-propensity-scores-as-controls/td-p/358457" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Selecting-the-closest-4-propensity-scores-as-controls/td-p/358457&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by customerID descending amount;
run;

data want;
set have;
by customerID;

if first.caseID then count=0;
count+1;

if count &amp;lt;= 2;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 May 2017 19:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Top-two-records-by-customer-group/m-p/358465#M84235</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-13T19:22:16Z</dc:date>
    </item>
  </channel>
</rss>

