<?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 Changing variable from char to numeric after deleting text entries? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626238#M184676</link>
    <description>&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I have a variable, NSAT_M, that lists SAT scores. However, for those who are missing SAT scores, 'N/A' was entered into this variable column. Thus, when I imported the Excel into SAS, it identified NSAT_M as a character variable.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I was able to use the DELETE statement to remove any observations with the 'N/A' value in the NSAT_M field, but this does not solve my problem of NSAT_M still being considered a character variable.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Is there a way for me to change the variable to numeric, even though those 'N/A' entries still exist in the original file?&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;From what I've found online so far, this isn't possible. I realize that the easy way to do this would be to remove any 'N/A's from the original Excel file and then reimport it to SAS so that it's automatically characterized as a numeric variable, but (for some reason) my supervisor is telling me I need to figure out a way to do this directly in SAS without altering the Excel file.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Any help would be appreciated!&lt;/P&gt;</description>
    <pubDate>Thu, 20 Feb 2020 17:46:09 GMT</pubDate>
    <dc:creator>DamianSilas</dc:creator>
    <dc:date>2020-02-20T17:46:09Z</dc:date>
    <item>
      <title>Changing variable from char to numeric after deleting text entries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626238#M184676</link>
      <description>&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I have a variable, NSAT_M, that lists SAT scores. However, for those who are missing SAT scores, 'N/A' was entered into this variable column. Thus, when I imported the Excel into SAS, it identified NSAT_M as a character variable.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I was able to use the DELETE statement to remove any observations with the 'N/A' value in the NSAT_M field, but this does not solve my problem of NSAT_M still being considered a character variable.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Is there a way for me to change the variable to numeric, even though those 'N/A' entries still exist in the original file?&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;From what I've found online so far, this isn't possible. I realize that the easy way to do this would be to remove any 'N/A's from the original Excel file and then reimport it to SAS so that it's automatically characterized as a numeric variable, but (for some reason) my supervisor is telling me I need to figure out a way to do this directly in SAS without altering the Excel file.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Any help would be appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 17:46:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626238#M184676</guid>
      <dc:creator>DamianSilas</dc:creator>
      <dc:date>2020-02-20T17:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Changing variable from char to numeric after deleting text entries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626241#M184677</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313106"&gt;@DamianSilas&lt;/a&gt;&amp;nbsp; How about using a Custom informat and then do whatever once the new variable with the right values is set as numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, _Same_ is read the value as is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
 invalue conv
 'N/A'=.
 other=_same_
 ;
run;
 data have;
  input var $;
 cards;
12
20
6
N/A
34
;

data want;
set have;
new_var=input(var,conv8.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Feb 2020 17:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626241#M184677</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-20T17:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Changing variable from char to numeric after deleting text entries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626262#M184685</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313106"&gt;@DamianSilas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approach could be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=var rename=(var_num = var));
	set have;
	if strip(var) = 'N/A' then var = '' ; /* var = character variable */
	var_num=input(var, best8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 18:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626262#M184685</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-20T18:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Changing variable from char to numeric after deleting text entries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626271#M184691</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp; Good thinking. If you do want to try the traditional method, add the&amp;nbsp;&lt;STRONG&gt;?? modifier&lt;/STRONG&gt; spice up your input function, so you don't have to conditionally execute &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Have fun! cheers!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var $;
cards;
12
20
6
N/A
34
;

data want (drop=var rename=(var_num = var));
	set have;
	*if strip(var) = 'N/A' then var = '' ; /* var = character variable */
	var_num=input(var,?? best8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Feb 2020 18:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626271#M184691</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-20T18:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Changing variable from char to numeric after deleting text entries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626278#M184695</link>
      <description>&lt;P&gt;Thanks for the tip &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;! Always on top&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 18:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-variable-from-char-to-numeric-after-deleting-text/m-p/626278#M184695</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-20T18:43:08Z</dc:date>
    </item>
  </channel>
</rss>

