<?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: Selecting top two values for a variable that has a rolling sum in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81827#M256657</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Reeza and Lillin. I sorted the data and used nested if-do loop. it worked. Thanks, Rk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Jan 2013 04:46:15 GMT</pubDate>
    <dc:creator>RajK</dc:creator>
    <dc:date>2013-01-24T04:46:15Z</dc:date>
    <item>
      <title>Selecting top two values for a variable that has a rolling sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81823#M256653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could some one answer my question?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to find top two values for a variable (say top_car_make) that is found based on summary variable (cars_sold) over last tweleve months for each friday. Each friday we have to look back twelve months and calculate top two cars sold for a dealer. The obs are grouped as dealerID, car_make and date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,RK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 15:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81823#M256653</guid>
      <dc:creator>RajK</dc:creator>
      <dc:date>2013-01-22T15:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting top two values for a variable that has a rolling sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81824#M256654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have the rolling sum portion and need to find the top two of a variable?&lt;/P&gt;&lt;P&gt;If so you could add a sort and then take the first two observations from your final dataset per dealer_id. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 15:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81824#M256654</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-22T15:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting top two values for a variable that has a rolling sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81825#M256655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza, Thank you for the response. I am using the following code to get top two dealers for each event date (that is each friday) but I couldn't get because the count is increasing by 1 for each dealer on the same date itself. Could you help me out with this? proc sort data=dealers; by&amp;nbsp; event_dt id descending size; run; data lib.dealers; set dealers; by&amp;nbsp; event_dt id; retain count 0; if first.event_dt and first.id then count=1; else count=count+1; run; Thanks, RK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jan 2013 16:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81825#M256655</guid>
      <dc:creator>RajK</dc:creator>
      <dc:date>2013-01-23T16:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting top two values for a variable that has a rolling sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81826#M256656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is the code helpful?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=dealers;&lt;/P&gt;&lt;P&gt;by&amp;nbsp; id event_dt&amp;nbsp; descending size; run;&lt;/P&gt;&lt;P&gt;data lib.dealers;&lt;/P&gt;&lt;P&gt;set dealers;&lt;/P&gt;&lt;P&gt;by&amp;nbsp; id event_dt;&lt;/P&gt;&lt;P&gt;if first.event_dt then count=0;&lt;/P&gt;&lt;P&gt;count+1;&lt;/P&gt;&lt;P&gt;if count&amp;lt;3 then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jan 2013 18:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81826#M256656</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-01-23T18:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting top two values for a variable that has a rolling sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81827#M256657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Reeza and Lillin. I sorted the data and used nested if-do loop. it worked. Thanks, Rk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 04:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-top-two-values-for-a-variable-that-has-a-rolling-sum/m-p/81827#M256657</guid>
      <dc:creator>RajK</dc:creator>
      <dc:date>2013-01-24T04:46:15Z</dc:date>
    </item>
  </channel>
</rss>

