<?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 check if a variable is numeric and convert to a character with a condition? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376628#M276634</link>
    <description>&lt;P&gt;Thank you for the quick reply.&lt;/P&gt;&lt;P&gt;Although this one runs and changes the data type ; the value is missing&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jul 2017 16:04:36 GMT</pubDate>
    <dc:creator>jjames1</dc:creator>
    <dc:date>2017-07-17T16:04:36Z</dc:date>
    <item>
      <title>How to check if a variable is numeric and convert to a character with a condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376619#M276632</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;&lt;P&gt;I am just following up with my question in&amp;nbsp;&lt;A title="Check if the variable is numeric" href="https://communities.sas.com/t5/General-SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376593#M48181" target="_self"&gt;Check if the variable is numeric then convert to Char&lt;/A&gt;&amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all for your valuable replies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my case I am reading from different XML files, So I dont know if it is &lt;EM&gt;&lt;STRONG&gt;numeric&lt;/STRONG&gt; &lt;/EM&gt;or &lt;EM&gt;&lt;STRONG&gt;character&lt;/STRONG&gt;&lt;/EM&gt; datatype originally. So ideally what I need to do is something like&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if (%sysfunc(vartype(xyz.myVar)) = N) %then  %do;
put(xyz.myVar,$5.);
%end

proc sql;
  create table abc as 
  select myvar
  from xyz;
  quit;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this way no matter what the data type is , I can always read a character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 15:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376619#M276632</guid>
      <dc:creator>jjames1</dc:creator>
      <dc:date>2017-07-17T15:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a variable is numeric and convert to a character with a condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376625#M276633</link>
      <description>&lt;P&gt;I think the CAT solution proposed would work, did that not work for your for some reason?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option missing='';
data class;
set sashelp.class;
if name in ('Alfred' 'Jane') then age=.;
run;


proc sql;
create table want as
select name, catt(age) as age, weight, height
from class;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2017 15:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376625#M276633</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-17T15:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a variable is numeric and convert to a character with a condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376628#M276634</link>
      <description>&lt;P&gt;Thank you for the quick reply.&lt;/P&gt;&lt;P&gt;Although this one runs and changes the data type ; the value is missing&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 16:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376628#M276634</guid>
      <dc:creator>jjames1</dc:creator>
      <dc:date>2017-07-17T16:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a variable is numeric and convert to a character with a condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376635#M276635</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151007"&gt;@jjames1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for the quick reply.&lt;/P&gt;
&lt;P&gt;Although this one runs and changes the data type ; the value is missing&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't understand what that means.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 16:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376635#M276635</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-17T16:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a variable is numeric and convert to a character with a condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376644#M276636</link>
      <description>&lt;P&gt;Hello Reeza,&lt;/P&gt;&lt;P&gt;It was an error from my side.&lt;/P&gt;&lt;P&gt;This way of conversion worked.&lt;/P&gt;&lt;P&gt;Thank you so much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 16:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-variable-is-numeric-and-convert-to-a-character/m-p/376644#M276636</guid>
      <dc:creator>jjames1</dc:creator>
      <dc:date>2017-07-17T16:36:06Z</dc:date>
    </item>
  </channel>
</rss>

