<?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: Most popular value from a text string in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164390#M42628</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Miance,&lt;/P&gt;&lt;P&gt;I do not know how many rows of data you are working with; the length of the source variable; nor whether you want the new variable on the same row as the original variable.&amp;nbsp; Are the values in the variable limited to the 26 letters in the alphabet?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 May 2014 12:03:48 GMT</pubDate>
    <dc:creator>jwillis</dc:creator>
    <dc:date>2014-05-19T12:03:48Z</dc:date>
    <item>
      <title>Most popular value from a text string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164389#M42627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to pull out the most popular value from a text string and create a new variable that tells me what it is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'AAAABBBCCD' would give me a new variable with the value of 'A' in this instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 11:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164389#M42627</guid>
      <dc:creator>mlance</dc:creator>
      <dc:date>2014-05-19T11:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Most popular value from a text string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164390#M42628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Miance,&lt;/P&gt;&lt;P&gt;I do not know how many rows of data you are working with; the length of the source variable; nor whether you want the new variable on the same row as the original variable.&amp;nbsp; Are the values in the variable limited to the 26 letters in the alphabet?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 12:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164390#M42628</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-05-19T12:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Most popular value from a text string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164391#M42629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please clarify the requirements.&amp;nbsp; There are many string functions, as can be found in the docs: &lt;A href="http://support.sas.com/publishing/pubcat/chaps/59343.pdf" title="http://support.sas.com/publishing/pubcat/chaps/59343.pdf"&gt;http://support.sas.com/publishing/pubcat/chaps/59343.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However its dependant on your specific scenario.&amp;nbsp; A simple calculation on the A or B or C etc. is relatively straight-forward, however its probably unlikely you want that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 12:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164391#M42629</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-05-19T12:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: Most popular value from a text string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164392#M42630</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;The following gives "A":&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; length want $1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; have='AAAABBBCCD';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; text=have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; max=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do until(lengthn(text)=0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; achar=substr(text,1,1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tally=countc(trim(text),achar);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if tally gt max then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; want=achar;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max=tally;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text=compress(text,achar);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put want=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 12:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164392#M42630</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2014-05-19T12:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Most popular value from a text string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164393#M42631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="807378" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; I had the pretty much the same idea as you with slightly different functions.&amp;nbsp; I made a list for ties.&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;_null_&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; s &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$char32.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ws=compress(s,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;); &lt;/SPAN&gt;&lt;SPAN style="color: #008000; background-color: #ffffff;"&gt;*don't count spaces;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;do&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;while&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(not missing(ws));&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; l=first(ws);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c=countc(ws,l,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'TI'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;); &lt;/SPAN&gt;&lt;SPAN style="color: #008000; background-color: #ffffff;"&gt;*add I to ignore case;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m=max(m,c);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; p $&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;32&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p=ifc(c eq m,catt(p,l),p);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws=compress(ws,l,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'I'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;); &lt;/SPAN&gt;&lt;SPAN style="color: #008000; background-color: #ffffff;"&gt;*add I to ignore case;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;end&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;put&lt;/SPAN&gt; &lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'NOTE: Most popular character(s) :'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; p &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'frequency:'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; m;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;AA&amp;nbsp; aaBBBCCD&lt;BR /&gt;CcC&amp;nbsp; AA&amp;nbsp; AABBBCCD&lt;BR /&gt;lkdjLabnejndkijdidnd&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 13:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164393#M42631</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-05-19T13:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Most popular value from a text string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164394#M42632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;data temp;
 set sashelp.class(keep=name);
 do i=1 to length(name);
&amp;nbsp; char=upcase(char(name,i));
&amp;nbsp; output;
 end;
 drop i;
run;
proc freq data=temp order=freq noprint;
by name;
tables char /out=temp1(drop=percent) nopercent ;
run;
data want;
 set temp1;
 by name;
 if first.name;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 13:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164394#M42632</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-05-19T13:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Most popular value from a text string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164395#M42633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks all for your help, I have a solution that works now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 15:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164395#M42633</guid>
      <dc:creator>mlance</dc:creator>
      <dc:date>2014-05-19T15:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Most popular value from a text string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164396#M42634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks very much Amir this works how I wanted it to.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 15:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164396#M42634</guid>
      <dc:creator>mlance</dc:creator>
      <dc:date>2014-05-19T15:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Most popular value from a text string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164397#M42635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm wondering why since &lt;A __default_attr="807378" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; gave you the program that "works how you wanted" that you did not mark the reply correct but merely helpful which leaves your question "Not Answered".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 16:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164397#M42635</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-05-19T16:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Most popular value from a text string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164398#M42636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Updated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 May 2014 07:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Most-popular-value-from-a-text-string/m-p/164398#M42636</guid>
      <dc:creator>mlance</dc:creator>
      <dc:date>2014-05-20T07:37:42Z</dc:date>
    </item>
  </channel>
</rss>

