<?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 convert numeric values to NA in an alphanumeric variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859772#M339655</link>
    <description>&lt;P&gt;Here are a few possibilities to consider, before deciding on a solution.&amp;nbsp; Would the values below:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;stay as is&lt;/LI&gt;
&lt;LI&gt;change to "NA"&lt;/LI&gt;
&lt;LI&gt;doesn't matter, it won't happen&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1 3 5      /* embedded blanks  */
3.1415     /* decimal point    */
    246    /* leading blanks   */
-789       /* negative sign    */
+987       /* positive sign    */
+ 246     /* combinations      */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If these are too easy, you might want to consider scientific notation such as&amp;nbsp; 314159E-5&lt;/P&gt;</description>
    <pubDate>Mon, 20 Feb 2023 20:21:05 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2023-02-20T20:21:05Z</dc:date>
    <item>
      <title>How to convert numeric values to NA in an alphanumeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859720#M339638</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a character variable that contains values that only include characters, values that only contain numeric, and other values that contain a combination of both numeric and alpha characters. I have included a small list of potential variable values below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1811&lt;/P&gt;&lt;P&gt;1826&lt;/P&gt;&lt;P&gt;1st airport&amp;nbsp;&lt;/P&gt;&lt;P&gt;1000 islands&lt;/P&gt;&lt;P&gt;1111&lt;/P&gt;&lt;P&gt;: Heathrow&lt;/P&gt;&lt;P&gt;9928&lt;/P&gt;&lt;P&gt;&amp;nbsp;: Seattle&amp;nbsp;&lt;/P&gt;&lt;P&gt;AC2277&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to recode values that only contain numerics as "NA" (i.e obs 1, 2, 5, 7), and I was wondering if anyone had any idea on how this can be done? The dataset I am working with is quite large (observations in the millions), so manually re-coding this variable based on the proc freq outputs can be quite exhaustive.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips you would have to resolve this issue, would be very much appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 14:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859720#M339638</guid>
      <dc:creator>jnivi</dc:creator>
      <dc:date>2023-02-20T14:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert numeric values to NA in an alphanumeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859724#M339641</link>
      <description>&lt;P&gt;Sometimes, the COMPRESS() function can be used to handle situations like this, if you use the third argument. (There are lots of ways you can define what kinds of characters to keep or drop, so COMPRESS() is really quite handy. Especially for people like me who cannot use regex to save my life.&amp;nbsp; Note that there is nothing in the second argument of the "COMPRESS" function because I am not listing out the digits that I'd like to keep.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input x $ 50.;
cards;
1811
1826
1st airport 
1000 islands
1111
: Heathrow
9928
 : Seattle 
AC2277
;
run;
proc print;
run;
data have2;
  set have;
  put y $char50.;
  x1 = compress(x, , 'kd');
  if x1 EQ x then y = 'NA';
  else y= x;
  run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 15:24:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859724#M339641</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2023-02-20T15:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert numeric values to NA in an alphanumeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859733#M339644</link>
      <description>&lt;P&gt;There is a NOTDIGIT function that could be used.&amp;nbsp; It returns 0 if a string is all digits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  input x $ 50.;

  length y $50 ;
  if notdigit(trim(x)) = 0 then y='NA' ;
  else y=x ;

cards;
1811
1826
1st airport 
1000 islands
1111
: Heathrow
9928
 : Seattle 
AC2277

;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 16:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859733#M339644</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-02-20T16:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert numeric values to NA in an alphanumeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859772#M339655</link>
      <description>&lt;P&gt;Here are a few possibilities to consider, before deciding on a solution.&amp;nbsp; Would the values below:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;stay as is&lt;/LI&gt;
&lt;LI&gt;change to "NA"&lt;/LI&gt;
&lt;LI&gt;doesn't matter, it won't happen&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1 3 5      /* embedded blanks  */
3.1415     /* decimal point    */
    246    /* leading blanks   */
-789       /* negative sign    */
+987       /* positive sign    */
+ 246     /* combinations      */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If these are too easy, you might want to consider scientific notation such as&amp;nbsp; 314159E-5&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 20:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859772#M339655</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-02-20T20:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert numeric values to NA in an alphanumeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859779#M339660</link>
      <description>&lt;P&gt;Thank you so much!! This solution worked perfectly!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 20:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-values-to-NA-in-an-alphanumeric-variable/m-p/859779#M339660</guid>
      <dc:creator>jnivi</dc:creator>
      <dc:date>2023-02-20T20:59:08Z</dc:date>
    </item>
  </channel>
</rss>

