<?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 find the variable is numeric or not in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519935#M140931</link>
    <description>&lt;P&gt;Then Check NOTDIGIT() ANYDIGIT()+COMPRESS().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Dec 2018 12:43:33 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-12-10T12:43:33Z</dc:date>
    <item>
      <title>how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519907#M140912</link>
      <description>&lt;P&gt;Hii&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am practicing SAS with dummy datasets i came across this condition where a variables contains both numeric and character .&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Data 1&lt;/TD&gt;&lt;TD&gt;Data 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;present&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;abs&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;332&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;not defined&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i got a condition like&lt;/P&gt;&lt;P&gt;(i)if data1 is numeric and data 2 is not missing then data3=data1&lt;/P&gt;&lt;P&gt;(ii) if data 1 is not numeric then data 4 is null&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can anyone please help me how to solve this ....thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 11:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519907#M140912</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2018-12-10T11:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519913#M140916</link>
      <description>&lt;P&gt;Use the &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245993.htm" target="_self"&gt;VTYPE Function&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519913#M140916</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-10T12:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519916#M140918</link>
      <description>&lt;P&gt;Check VTYPE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
 set sashelp.class;
 t1=vtype(name);
 t2=vtype(age);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519916#M140918</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-10T12:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519917#M140919</link>
      <description>for vartype we have to use array function....cant we find it out without using array</description>
      <pubDate>Mon, 10 Dec 2018 12:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519917#M140919</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2018-12-10T12:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519920#M140920</link>
      <description>&lt;P&gt;Some to think of it, I don't think you are actually interested in the type of the variable. You want to know whether the variable value can be represented as a number, correct?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519920#M140920</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-10T12:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519922#M140921</link>
      <description>if the type of the variable is numeric then i have apply those condition</description>
      <pubDate>Mon, 10 Dec 2018 12:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519922#M140921</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2018-12-10T12:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519925#M140922</link>
      <description>what if the number is also stored in character format vtype returns as C even for that</description>
      <pubDate>Mon, 10 Dec 2018 12:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519925#M140922</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2018-12-10T12:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519926#M140923</link>
      <description>&lt;P&gt;The type of the Data1 is always character. otherwise the value "present" could not be there. That means that the value "12" is also character here.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519926#M140923</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-10T12:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519928#M140925</link>
      <description>yes</description>
      <pubDate>Mon, 10 Dec 2018 12:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519928#M140925</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2018-12-10T12:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519931#M140928</link>
      <description>&lt;P&gt;I think this may be a starting point to what you want to do. Here, I use the INPUT function to determine whether Data1 can be meaningfully represented as a number.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I apply your logic to the best of my ability.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length Data1 $20;
input Data1 $ Data2;
infile datalines dlm=',';
datalines;
present,4
abs,6
12,9
332,.
21,.
31,.
27,4
not defined,7
;

options nonotes;
data want(drop=a);
   set have;
   a=input(Data1, best.);
   if (a ne .) and data2 ne . then data3=a;
   if a eq . then data4=.;
run;
options notes;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519931#M140928</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-10T12:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519935#M140931</link>
      <description>&lt;P&gt;Then Check NOTDIGIT() ANYDIGIT()+COMPRESS().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519935#M140931</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-10T12:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519937#M140933</link>
      <description>&lt;P&gt;Or Try the following code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 t1='1234.23 ';
 x1=resolve(cats('%datatyp(',t1,')'));
 put t1= x1=;

 t2='23232   ';
 x2=resolve(cats('%datatyp(',t2,')'));
 put t2= x2=;

 t3='2344wew';
 x3=resolve(cats('%datatyp(',t3,')'));
 put t3= x3=;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519937#M140933</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-10T12:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519939#M140934</link>
      <description>&lt;PRE&gt;data want;
  set have;
  if lengthn(compress(data1,"","d"))=0 and data2 ne . then data3=input(data1,best.);
  else data4=.;
run;
&lt;/PRE&gt;
&lt;P&gt;Gotta say, you logic doesn't make much sense, data4 will always be . even if the condition else is true.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/519939#M140934</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-10T12:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/521112#M141373</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/245051"&gt;@Aayushi_17&lt;/a&gt;, let me just emphasize that though I tried to apply your logic, it does not make much sense as data4 will result in a missing value no matter what.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 12:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/521112#M141373</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-13T12:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the variable is numeric or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/521117#M141376</link>
      <description>&lt;P&gt;the numeric is stored in character value which i have to convert and after that i will get the number as output in data 4 and the character values like present will return as null in data 4&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 12:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-variable-is-numeric-or-not/m-p/521117#M141376</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2018-12-13T12:30:07Z</dc:date>
    </item>
  </channel>
</rss>

