<?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: Convert char to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503710#M134651</link>
    <description>&lt;P&gt;3807 /*Changing char to numeric of agent_code*/&lt;BR /&gt;3808 data Rtl_Rpt.IAR;&lt;BR /&gt;3809 set IAR(rename=(AGENT_CODE=AGENT_CODE1));&lt;BR /&gt;3810 AGENT_CODE=input(AGENT_CODE1,BEST12.);&lt;BR /&gt;3811 run;&lt;/P&gt;&lt;P&gt;NOTE: Data file RTL_RPT.IAR.DATA is in a format that is native to another host, or the file&lt;BR /&gt;encoding does not match the session encoding. Cross Environment Data Access will be&lt;BR /&gt;used, which might require additional CPU resources and might reduce performance.&lt;BR /&gt;NOTE: Invalid argument to function INPUT at line 3810 column 16.&lt;BR /&gt;AGENT_CODE1=AGENT_CODE NAME=NAME FILING_STATUS_IND=FILING_STATUS_IND&lt;BR /&gt;DATE_IAR_BEGIN=DATE_IAR_BEGIN DATE_IAR_END=DATE_IAR_END YES=YES AGENT_CODE=. _ERROR_=1&lt;BR /&gt;_N_=3359&lt;BR /&gt;NOTE: Mathematical operations could not be performed at the following places. The results of&lt;BR /&gt;the operations have been set to missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;1 at 3810:16&lt;BR /&gt;NOTE: There were 3359 observations read from the data set WORK.IAR.&lt;BR /&gt;NOTE: The data set RTL_RPT.IAR has 3359 observations and 7 variables.&lt;BR /&gt;NOTE: Compressing data set RTL_RPT.IAR decreased size by 16.67 percent.&lt;BR /&gt;Compressed is 5 pages; un-compressed would require 6 pages.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 2.17 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Oct 2018 13:06:48 GMT</pubDate>
    <dc:creator>sg_kr</dc:creator>
    <dc:date>2018-10-12T13:06:48Z</dc:date>
    <item>
      <title>Convert char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503696#M134643</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when i am importing data from excel sheet, the field agent code is getting as character.&lt;/P&gt;&lt;P&gt;when i join this with other table its throws an error of invalid datatype .&lt;/P&gt;&lt;P&gt;so i want to change the datatype of the dataset which i imported,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can i do it while importing itself or give me other suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here the code which i am importing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC IMPORT OUT= IAR&lt;BR /&gt;/* changed the file name to import form XLSX*/&lt;BR /&gt;DATAFILE= "----------------------------------------------------------s\qry_results1.xlsx"&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;DBMS=XLSX REPLACE;&lt;BR /&gt;/* RANGE="APPS_Total";*/&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;/* MIXED=NO;*/&lt;BR /&gt;/* SCANTEXT=YES;*/&lt;BR /&gt;/* USEDATE=YES;*/&lt;BR /&gt;/* SCANTIME=YES;*/&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also i tried to convert the variable with below steps and its not happening.&lt;/P&gt;&lt;P&gt;data Rtl_Rpt.IAR;&lt;BR /&gt;set IAR;&lt;BR /&gt;AGENT_CODE=input(AGENT_CODE,8..);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;please help&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 12:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503696#M134643</guid>
      <dc:creator>sg_kr</dc:creator>
      <dc:date>2018-10-12T12:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503698#M134645</link>
      <description>&lt;P&gt;As long as you use Excel files, you are subject to the guessing of the SAS access methods for that. Excel does not have the concept of a fixed column type that is prevalent in databases.&lt;/P&gt;
&lt;P&gt;If you want go take control over the data transfer process, abandon the Excel format. Save the data to a csv file and import that with a custom written datastep, where &lt;EM&gt;you&lt;/EM&gt; specify types and other attributes.&lt;/P&gt;
&lt;P&gt;If you need to convert variable x from character to numeric, you need to replace the variable with a new one, as you cannot change its type:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data out;
set in (rename=(x=_x));
x = input(_x,best32.);
drop _x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Oct 2018 12:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503698#M134645</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-12T12:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503707#M134649</link>
      <description>&lt;P&gt;Thanks for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried this earlier but this is not working&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 13:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503707#M134649</guid>
      <dc:creator>sg_kr</dc:creator>
      <dc:date>2018-10-12T13:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Convert char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503708#M134650</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215304"&gt;@sg_kr&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i tried this earlier but this is not working&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please post the log from that step.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 13:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503708#M134650</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-12T13:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503710#M134651</link>
      <description>&lt;P&gt;3807 /*Changing char to numeric of agent_code*/&lt;BR /&gt;3808 data Rtl_Rpt.IAR;&lt;BR /&gt;3809 set IAR(rename=(AGENT_CODE=AGENT_CODE1));&lt;BR /&gt;3810 AGENT_CODE=input(AGENT_CODE1,BEST12.);&lt;BR /&gt;3811 run;&lt;/P&gt;&lt;P&gt;NOTE: Data file RTL_RPT.IAR.DATA is in a format that is native to another host, or the file&lt;BR /&gt;encoding does not match the session encoding. Cross Environment Data Access will be&lt;BR /&gt;used, which might require additional CPU resources and might reduce performance.&lt;BR /&gt;NOTE: Invalid argument to function INPUT at line 3810 column 16.&lt;BR /&gt;AGENT_CODE1=AGENT_CODE NAME=NAME FILING_STATUS_IND=FILING_STATUS_IND&lt;BR /&gt;DATE_IAR_BEGIN=DATE_IAR_BEGIN DATE_IAR_END=DATE_IAR_END YES=YES AGENT_CODE=. _ERROR_=1&lt;BR /&gt;_N_=3359&lt;BR /&gt;NOTE: Mathematical operations could not be performed at the following places. The results of&lt;BR /&gt;the operations have been set to missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;1 at 3810:16&lt;BR /&gt;NOTE: There were 3359 observations read from the data set WORK.IAR.&lt;BR /&gt;NOTE: The data set RTL_RPT.IAR has 3359 observations and 7 variables.&lt;BR /&gt;NOTE: Compressing data set RTL_RPT.IAR decreased size by 16.67 percent.&lt;BR /&gt;Compressed is 5 pages; un-compressed would require 6 pages.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 2.17 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 13:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503710#M134651</guid>
      <dc:creator>sg_kr</dc:creator>
      <dc:date>2018-10-12T13:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Convert char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503712#M134652</link>
      <description>&lt;P&gt;If your trying this way it wont work, since AGENT_CODE is already defined as Character. You need to rename the variable before reading it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* This will not work */
data Rtl_Rpt.IAR;
set IAR;
AGENT_CODE=input(AGENT_CODE,8..);
run;
/* This will work*/
data Rtl_Rpt.IAR(Drop=AGENT_DUMMY);
set IAR(rename=(AGENT_CODE=AGENT_CODE_DUMMY));
AGENT_CODE=input(AGENT_CODE_DUMMY,8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 13:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503712#M134652</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-12T13:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Convert char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503713#M134653</link>
      <description>&lt;P&gt;It looks like your last observation (the last row in Excel) contains another header, so you have to filter that one out:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Rtl_Rpt.IAR;
set IAR(rename=(AGENT_CODE=AGENT_CODE1));
if AGENT_CODE1 ne 'AGENT_CODE';
AGENT_CODE=input(AGENT_CODE1,BEST12.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can see that the error happens only once in data step iteration 3359 (_N_=3359), which corresponds to the overall number of observations in the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 13:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-char-to-numeric/m-p/503713#M134653</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-12T13:12:11Z</dc:date>
    </item>
  </channel>
</rss>

