<?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: Converting from character to Numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487555#M287273</link>
    <description>&lt;P&gt;Can you export the file as a CSV instead and import that? Do you have/can you make a specification document that indicates what every variable should be in terms of type and format? You have more control over your import this way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will still have to verify each field individually, but data quality is pretty much the most important step. The usual method for me is to use PROC IMPORT with a CSV and then copy the code from the log and manually modify it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/180186"&gt;@127&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have hundreds of variables like age, type, etc. that are not in particular order and have different lengths. I need to be converted thme from character into numeric variables (this file was exported from a web-bases system into excel, which then i am importing the excel into SAS). I don't want to use the&amp;nbsp;&lt;STRONG&gt;input&amp;nbsp;&lt;/STRONG&gt;and&amp;nbsp;&lt;STRONG&gt;drop&amp;nbsp;&lt;/STRONG&gt;statements because that would be a labor intensive. Any ideas for code I can use?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Aug 2018 19:12:14 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-08-16T19:12:14Z</dc:date>
    <item>
      <title>Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487553#M287272</link>
      <description>&lt;P&gt;I have hundreds of variables like age, type, etc. that are not in particular order and have different lengths. I need to be converted thme from character into numeric variables (this file was exported from a web-bases system into excel, which then i am importing the excel into SAS). I don't want to use the&amp;nbsp;&lt;STRONG&gt;input&amp;nbsp;&lt;/STRONG&gt;and&amp;nbsp;&lt;STRONG&gt;drop&amp;nbsp;&lt;/STRONG&gt;statements because that would be a labor intensive. Any ideas for code I can use?&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 19:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487553#M287272</guid>
      <dc:creator>127</dc:creator>
      <dc:date>2018-08-16T19:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487555#M287273</link>
      <description>&lt;P&gt;Can you export the file as a CSV instead and import that? Do you have/can you make a specification document that indicates what every variable should be in terms of type and format? You have more control over your import this way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will still have to verify each field individually, but data quality is pretty much the most important step. The usual method for me is to use PROC IMPORT with a CSV and then copy the code from the log and manually modify it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/180186"&gt;@127&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have hundreds of variables like age, type, etc. that are not in particular order and have different lengths. I need to be converted thme from character into numeric variables (this file was exported from a web-bases system into excel, which then i am importing the excel into SAS). I don't want to use the&amp;nbsp;&lt;STRONG&gt;input&amp;nbsp;&lt;/STRONG&gt;and&amp;nbsp;&lt;STRONG&gt;drop&amp;nbsp;&lt;/STRONG&gt;statements because that would be a labor intensive. Any ideas for code I can use?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 19:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487555#M287273</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-16T19:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487557#M287274</link>
      <description>&lt;P&gt;I can only import the data into excel, even after I save the excel file as CSV and import into SAS the formats sill remain the same (character).&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 19:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487557#M287274</guid>
      <dc:creator>127</dc:creator>
      <dc:date>2018-08-16T19:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487558#M287275</link>
      <description>&lt;P&gt;Can you please provide more information. Show some sample data and output you like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does this mean?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;I don't want to use the&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;input&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;and&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;drop&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;statements because that would be a labor intensive&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 16 Aug 2018 19:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487558#M287275</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-16T19:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487561#M287276</link>
      <description>&lt;P&gt;Then you imported the CSV file incorrectly. Did you use a data step or the copy/paste method I mentioned?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC IMPORT guesses and it often guesses incorrectly. If it's one time job you can set GUESSINGROWS=MAX and see if it works but if this is for any sort of repeatable process that is not recommended.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/180186"&gt;@127&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I can only import the data into excel, even after I save the excel file as CSV and import into SAS the formats sill remain the same (character).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 19:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487561#M287276</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-16T19:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487563#M287277</link>
      <description>&lt;P&gt;Data example in Excel that's currently in character&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;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R&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;1/15/2018&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;TD&gt;2/6/2018&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;95&lt;/TD&gt;&lt;TD&gt;6/4/2017&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also need to do this import quarterly. I can only download the data from the web-based system into excel.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 19:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487563#M287277</guid>
      <dc:creator>127</dc:creator>
      <dc:date>2018-08-16T19:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487565#M287278</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/180186"&gt;@127&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also need to do this import quarterly. I can only download the data from the web-based system into excel.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sigh, that's a problem. So you will then have to manually ensure &lt;U&gt;&lt;STRONG&gt;every&lt;/STRONG&gt;&lt;/U&gt; variable meets the type you need because you cannot guarantee that in an Excel file. And I do mean every variable even if it's not problematic in this data set because it could be in future data sets. Excel does not have the concept of types in columns similar to databases and that leads to these types of issues.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 19:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487565#M287278</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-16T19:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487567#M287279</link>
      <description>&lt;P&gt;that's what I wondered but I thought that maybe someone had a better answer. I appreciate your time looking into this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 19:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487567#M287279</guid>
      <dc:creator>127</dc:creator>
      <dc:date>2018-08-16T19:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487569#M287280</link>
      <description>&lt;P&gt;Convert to CSV as a step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VBS script to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'Set the parameters of the program

'Original extension of files - note this is case sensitive
oldExt = "xlsx"

'New extension desired
newExt = "csv"

'code for new extension
newExtCode = 6

'common codes include:
'xlsx=51
'xls=-4143
'csv=6
'xml=46

'path to folders with files to convert
path2File = "C:\_LOCALdata\temp\Temp\"


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Do not change below this line
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

set xlapp = CreateObject("Excel.Application")
set fso = CreateObject("scripting.filesystemobject")
set myfolder = fso.GetFolder(path2File)
set myfiles = myfolder.Files
xlapp.DisplayAlerts = False
 
for each f in myfiles
  ExtName = fso.GetExtensionName(f)
  Filename= fso.GetBaseName(f)
    if ExtName=oldExt then
           set mybook = xlapp.Workbooks.Open(f.Path)
           xlapp.Visible = false
           mybook.SaveAs path2File &amp;amp; Filename &amp;amp; "." &amp;amp; newExt, newExtCode
    End If
  Next
  mybook.Close
  xlapp.DisplayAlerts = False
 xlapp.Quit
 Set xlapp = Nothing
 strScript = Wscript.ScriptFullName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Aug 2018 19:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487569#M287280</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-16T19:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487571#M287281</link>
      <description>&lt;P&gt;Did you check will PROC HTTP work for you. Instead of creating a excel file and then importing it into SAS, you can directly read the data from web using PROC HTTP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2017/12/04/scrape-web-page-data/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2017/12/04/scrape-web-page-data/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 20:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487571#M287281</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-16T20:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from character to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487573#M287282</link>
      <description>&lt;P&gt;I did not check and I am not sure that's possible. The data are stored in web-based application that's custom built for us and it's password protected.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 20:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-character-to-Numeric/m-p/487573#M287282</guid>
      <dc:creator>127</dc:creator>
      <dc:date>2018-08-16T20:11:37Z</dc:date>
    </item>
  </channel>
</rss>

