<?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 convert char to numeric using array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876112#M346172</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to convert all char variables into numeric.&lt;/P&gt;
&lt;P&gt;In this case all char variables have digits so it is possible.&lt;/P&gt;
&lt;P&gt;What is the reason that in want data set I dont get numeric columns?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; Data have;
 input mon1 $ mon2 $ mon3 $ mon4 $ mon5 $ mon6 $;
 cards;
 2301 2302 2303 2303 2305 2306
;
 Run;

DATA want;
SET have;
ARRAY _char mon:;
ARRAY _num mon:;
DO i=1  to dim(_char);
_num{i} = input(_char{i},best.);
END;
RUN; 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 16 May 2023 21:49:39 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2023-05-16T21:49:39Z</dc:date>
    <item>
      <title>convert char to numeric using array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876112#M346172</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to convert all char variables into numeric.&lt;/P&gt;
&lt;P&gt;In this case all char variables have digits so it is possible.&lt;/P&gt;
&lt;P&gt;What is the reason that in want data set I dont get numeric columns?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; Data have;
 input mon1 $ mon2 $ mon3 $ mon4 $ mon5 $ mon6 $;
 cards;
 2301 2302 2303 2303 2305 2306
;
 Run;

DATA want;
SET have;
ARRAY _char mon:;
ARRAY _num mon:;
DO i=1  to dim(_char);
_num{i} = input(_char{i},best.);
END;
RUN; 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 May 2023 21:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876112#M346172</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-16T21:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: convert char to numeric using array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876116#M346174</link>
      <description>&lt;P&gt;You are referring to the same variables both as character and numeric, and a SAS variable cannot be of both datatype at the same time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to get new names for numeric vars, like _mon1-_mon6.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 22:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876116#M346174</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-05-16T22:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: convert char to numeric using array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876117#M346175</link>
      <description>&lt;P&gt;I have tried by your answer but got an error&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 Data have;
 input mon1 $ mon2 $ mon3 $ mon4 $ mon5 $ mon6 $;
 cards;
 2301 2302 2303 2303 2305 2306
;
 Run;

DATA want;
SET have;
ARRAY _char mon:;
ARRAY _num _mon:;
DO i=1  to dim(_char);
_num{i} = input(_char{i},best.);
END;
RUN; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The error&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: Array subscript out of range at line 39 column 17.
mon1=2301 mon2=2302 mon3=2303 mon4=2303 mon5=2305 mon6=2306 _I_=. i=1 _ERROR_=1 _N_=1
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1 observations read from the data set WORK.HAVE.
WARNING: The data set WORK.WANT may be incomplete.  When this step was stopped there were 0 observations and 7 variables.
WARNING: Data set WORK.WANT was not replaced because this step was stopped.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 May 2023 22:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876117#M346175</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-16T22:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: convert char to numeric using array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876119#M346176</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/converting-same-variable-name-from-char-to-numeric-in-the-same/td-p/817765" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/converting-same-variable-name-from-char-to-numeric-in-the-same/td-p/817765&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 22:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876119#M346176</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-16T22:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: convert char to numeric using array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876123#M346178</link>
      <description>&lt;P&gt;ARRAY _num &lt;STRONG&gt;_mon1-_mon6&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rename should be done outside the array&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 22:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876123#M346178</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-05-16T22:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: convert char to numeric using array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876141#M346187</link>
      <description>&lt;P&gt;You cannot use the : suffix to match variable names of variables that do not yet exist.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 00:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-char-to-numeric-using-array/m-p/876141#M346187</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-17T00:57:36Z</dc:date>
    </item>
  </channel>
</rss>

