<?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: Detecting letters in variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481084#M124401</link>
    <description>&lt;P&gt;Cheers Guys!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tried the methods and both work well and deliver the same result, thank you!&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jul 2018 11:40:44 GMT</pubDate>
    <dc:creator>NilsNoh</dc:creator>
    <dc:date>2018-07-25T11:40:44Z</dc:date>
    <item>
      <title>Detecting letters in variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481056#M124387</link>
      <description>&lt;P&gt;Hey Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this question was probably already asked before but I am not only new to SAS, but also new to this forum, so please bear with me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset where I wanted to sort a character variable with length 18, although it is a character variable it only contains numbers (IDs). If I try to sort this variable, I get an error because in at least one observation there are letters mixed into the ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I find out how many observations contain letters, I think I have to use the anyalpha command, but not quite sure how to apply it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 09:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481056#M124387</guid>
      <dc:creator>NilsNoh</dc:creator>
      <dc:date>2018-07-25T09:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting letters in variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481058#M124388</link>
      <description>&lt;P&gt;Can you use sortseq=linguistic (numeric_collation=on) in your proc sort?&lt;/P&gt;
&lt;P&gt;Anyhows:&lt;/P&gt;
&lt;PRE&gt;number_of_chars=lengthn(compress(id," ","ka"));&lt;/PRE&gt;
&lt;P&gt;Pop that in a datastep and it will tell you how many alphas are in the id string.&amp;nbsp; ka = keep alpha.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 09:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481058#M124388</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-25T09:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting letters in variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481076#M124398</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To find the number of observations, you could try &lt;FONT face="courier new,courier"&gt;proc sql&lt;/FONT&gt; as in the following example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* set up an id variable with some containing alphabetic characters */
data have;
   set sashelp.class;

   length id $ 8;

   /* add alphabetics to id if name begins with 'J' */
   if name eq: 'J' then
      id = cats('ABC',id);
   else
      id = cats(_n_);
run;

%let id_alpha = 0;

/* save the count of id's with alphabetic characters into a macro variable */
proc sql noprint;
   select
      count (*)
   into
      :id_alpha
   from
      have(keep = id)
   where
      anyalpha(id)
   ;
quit;

%put id_alpha = &amp;amp;id_alpha;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 10:57:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481076#M124398</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2018-07-25T10:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting letters in variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481079#M124399</link>
      <description>&lt;P&gt;Anyalpha is used to find the first occurrence of an alphabet in a string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
retain cnt 0;;
Num_of_Chars = lengthn(compress(ID,,'d')); *If you want to include special characters(if exist);
Num_of_Chars = lengthn(compress(ID,,'ka')); *If you have only alphabets and digits;
if Num_of_Chars gt 0 then cnt=cnt+1;
call symput("No_Of_Obs",cnt);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jul 2018 11:12:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481079#M124399</guid>
      <dc:creator>MadhuKorni</dc:creator>
      <dc:date>2018-07-25T11:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting letters in variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481084#M124401</link>
      <description>&lt;P&gt;Cheers Guys!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tried the methods and both work well and deliver the same result, thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 11:40:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481084#M124401</guid>
      <dc:creator>NilsNoh</dc:creator>
      <dc:date>2018-07-25T11:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting letters in variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481089#M124404</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222877"&gt;@NilsNoh&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can mark either solution as accepted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 12:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-letters-in-variables/m-p/481089#M124404</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2018-07-25T12:05:25Z</dc:date>
    </item>
  </channel>
</rss>

