<?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: identifying non-numeric values in a numeric variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505447#M135353</link>
    <description>Thanks for your reply. I think I understand the numeric data type in SAS. I am working with an external dataset in which the missing values are displayed both as "." and "C" and that's why I got confused. Thanks for clarification, though.</description>
    <pubDate>Thu, 18 Oct 2018 07:19:29 GMT</pubDate>
    <dc:creator>AmirSari</dc:creator>
    <dc:date>2018-10-18T07:19:29Z</dc:date>
    <item>
      <title>identifying non-numeric values in a numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505411#M135342</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a numeric variable that contains no-numeric and missing values in some cases. I am trying to identify and remove those cases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input&amp;nbsp; return;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;-0.031250&lt;/P&gt;&lt;P&gt;&amp;nbsp;0.000000&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;0.186340&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;want:&lt;/P&gt;&lt;P&gt;return&lt;/P&gt;&lt;P&gt;-0.031250&lt;/P&gt;&lt;P&gt;&amp;nbsp;0.000000&lt;/P&gt;&lt;P&gt;0.186340&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that when the variable is set to character there are different ways to do that, however when i try to convert the variable to character using the put function, the new variable will contain only zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 01:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505411#M135342</guid>
      <dc:creator>AmirSari</dc:creator>
      <dc:date>2018-10-18T01:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: identifying non-numeric values in a numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505412#M135343</link>
      <description>&lt;P&gt;Plz take a look at notdigit function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if notdigit(variable)=0;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 01:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505412#M135343</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-18T01:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: identifying non-numeric values in a numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505413#M135344</link>
      <description>&lt;P&gt;You question shows a bit of confusion.&lt;/P&gt;
&lt;P&gt;A numeric variable cannot contain letters.&lt;/P&gt;
&lt;P&gt;To read dirty data, you need to read as a character, then test that it's a valid number then save as a numeric.&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data HAVE;
  input RETURNC $;
  RETURN=input(RETURNC,?? dollar32.);
  if RETURN ne .;
cards;
-0.031250
 0.000000
C
.
0.186340
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.HAVE" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;RETURN&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;-0.03125&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;0.00000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;0.18634&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 02:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505413#M135344</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-10-18T02:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: identifying non-numeric values in a numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505440#M135350</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/102358"&gt;@AmirSari&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a numeric variable that contains no-numeric and missing values in some cases.&lt;/P&gt;
&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is plain impossible, so you are under some kind of misunderstanding of the numeric data type in SAS.&lt;/P&gt;
&lt;P&gt;A numeric variable in SAS can only contain numbers or missing values, period. You can define special missing values (apart from .), but they're still missing values.&lt;/P&gt;
&lt;P&gt;Non-numeric data can only be stored in character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So go back and review your post&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;is it about a SAS dataset or an external file that you want to import into SAS&lt;/LI&gt;
&lt;LI&gt;if a SAS dataset, run a proc contents and show the type of the variable in question. Also run a proc print of that variable and show values that are puzzling you&lt;/LI&gt;
&lt;LI&gt;if an external file, post some example lines, and what you want have in the resulting SAS dataset&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 18 Oct 2018 07:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505440#M135350</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-18T07:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: identifying non-numeric values in a numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505447#M135353</link>
      <description>Thanks for your reply. I think I understand the numeric data type in SAS. I am working with an external dataset in which the missing values are displayed both as "." and "C" and that's why I got confused. Thanks for clarification, though.</description>
      <pubDate>Thu, 18 Oct 2018 07:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505447#M135353</guid>
      <dc:creator>AmirSari</dc:creator>
      <dc:date>2018-10-18T07:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: identifying non-numeric values in a numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505449#M135354</link>
      <description>&lt;P&gt;When reading from an external file, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt; has provided the cleanest solution. It reads data as you want it, and the code has no ERRORs or WARNINGs of any kind.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 07:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/identifying-non-numeric-values-in-a-numeric-variable/m-p/505449#M135354</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-18T07:33:36Z</dc:date>
    </item>
  </channel>
</rss>

