<?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: How to assign rank to a character variable in a group? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315743#M68920</link>
    <description>&lt;P&gt;What is your definition of "top"? Most frequent value in the data, related to a value not shown (revenue, market share, show ratings, color of logo), or something less obvious?&lt;/P&gt;</description>
    <pubDate>Thu, 01 Dec 2016 00:10:21 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-12-01T00:10:21Z</dc:date>
    <item>
      <title>How to assign rank to a character variable in a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315736#M68918</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set that contains vendor, vendor&amp;nbsp;location, products , product category. I want to find out the top 5 products per vendor location, and vendor.&lt;/P&gt;
&lt;P&gt;eg: Vendor Vendor_loc products Prod_cat&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp; CA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TV &amp;nbsp; &amp;nbsp; &amp;nbsp;ENT&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp;CA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TV &amp;nbsp; &amp;nbsp; &amp;nbsp;ENT&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BCA &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;CA&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IPAD &amp;nbsp; &amp;nbsp; &amp;nbsp;ENT&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BCA &amp;nbsp; &amp;nbsp; &lt;SPAN&gt;CA&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TV&amp;nbsp; &amp;nbsp; &amp;nbsp;ENT&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;CA&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IPAD &amp;nbsp; &amp;nbsp; &amp;nbsp;ENT&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp; &amp;nbsp;CA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TV &amp;nbsp; &amp;nbsp; &amp;nbsp;ENT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Vendor Vendor_loc &amp;nbsp; products &amp;nbsp;rank&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ABC &amp;nbsp; &amp;nbsp; &amp;nbsp; CA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TV &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ABC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IPAD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; BCA &amp;nbsp; &amp;nbsp; &amp;nbsp; CA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IPAD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BCA &amp;nbsp; &amp;nbsp; &amp;nbsp;CA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TV &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please let me know how I can rank products(character variable) in a group?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 00:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315736#M68918</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-12-01T00:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign rank to a character variable in a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315740#M68919</link>
      <description>&lt;P&gt;Why are the two BCA ranks the same?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a tie, what ranks do you want to assign?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 00:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315740#M68919</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-01T00:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign rank to a character variable in a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315743#M68920</link>
      <description>&lt;P&gt;What is your definition of "top"? Most frequent value in the data, related to a value not shown (revenue, market share, show ratings, color of logo), or something less obvious?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 00:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315743#M68920</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-12-01T00:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign rank to a character variable in a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315744#M68921</link>
      <description>&lt;P&gt;If they there is tie then same rank or different rank is fine.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 00:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315744#M68921</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-12-01T00:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign rank to a character variable in a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315745#M68922</link>
      <description>&lt;P&gt;Vendor with most products in a location. For eg: ABC had TV as their top product(with rank 1) in CA .&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 00:13:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315745#M68922</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-12-01T00:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign rank to a character variable in a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315749#M68923</link>
      <description>&lt;P&gt;Here's one approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have noprint;&lt;/P&gt;
&lt;P&gt;tables vendor * vendor_loc * product / noprint out=counts (drop=percent);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=counts;&lt;/P&gt;
&lt;P&gt;by vendor vendor_loc descending count;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set counts;&lt;/P&gt;
&lt;P&gt;by vendor vendor_loc;&lt;/P&gt;
&lt;P&gt;if first.vendor_loc then rank=1;&lt;/P&gt;
&lt;P&gt;else rank + 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Conceivably you could drop COUNT at the end but I left it in because you might find it useful.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 01:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-rank-to-a-character-variable-in-a-group/m-p/315749#M68923</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-01T01:01:29Z</dc:date>
    </item>
  </channel>
</rss>

