<?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 attributing a rank to each modality starting with same word in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/attributing-a-rank-to-each-modality-starting-with-same-word/m-p/465947#M118863</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table sorted by alphabetical order who looks like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;felony&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs consumer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs seller&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs trafficker&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;murder in the first degree&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;murder in the second degree&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sex offender&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sex worker&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And what I'd like is to create a variable attributing a rank for each felony starting with the same word. Something like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;felony&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;rank&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs consumer&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs seller&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs trafficker&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;murder in the first degree&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;murder in the second degree&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sex offender&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sex worker&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help on this ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My final goal is to study if people tend to chose the first propositions when they have to pick an answer in a list in case of autocomplete text filled questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please excuse my english.&lt;/P&gt;</description>
    <pubDate>Wed, 30 May 2018 09:37:49 GMT</pubDate>
    <dc:creator>alex_philby</dc:creator>
    <dc:date>2018-05-30T09:37:49Z</dc:date>
    <item>
      <title>attributing a rank to each modality starting with same word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/attributing-a-rank-to-each-modality-starting-with-same-word/m-p/465947#M118863</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table sorted by alphabetical order who looks like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;felony&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs consumer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs seller&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs trafficker&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;murder in the first degree&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;murder in the second degree&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sex offender&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sex worker&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And what I'd like is to create a variable attributing a rank for each felony starting with the same word. Something like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;felony&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;rank&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs consumer&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs seller&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugs trafficker&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;murder in the first degree&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;murder in the second degree&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sex offender&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sex worker&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help on this ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My final goal is to study if people tend to chose the first propositions when they have to pick an answer in a list in case of autocomplete text filled questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please excuse my english.&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 09:37:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/attributing-a-rank-to-each-modality-starting-with-same-word/m-p/465947#M118863</guid>
      <dc:creator>alex_philby</dc:creator>
      <dc:date>2018-05-30T09:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: attributing a rank to each modality starting with same word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/attributing-a-rank-to-each-modality-starting-with-same-word/m-p/465951#M118867</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input felony $50.;
cards;
drugs consumer
drugs seller
drugs trafficker
murder in the first degree
murder in the second degree
sex offender
sex worker
;
run;

data have1;
set have;
first_word = scan(felony,1);
run;

data want;
set have1;
by first_word; /* add nostsorted if necessary */
if first.first_word
then rank = 1;
else rank + 1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 May 2018 10:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/attributing-a-rank-to-each-modality-starting-with-same-word/m-p/465951#M118867</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-30T10:25:41Z</dc:date>
    </item>
  </channel>
</rss>

