<?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: problem reading in xls file using proc import in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736619#M229520</link>
    <description>The structures for all the xls files are the same. I think it's the empty cells at the beginning of some files are causing the problem.</description>
    <pubDate>Fri, 23 Apr 2021 15:58:33 GMT</pubDate>
    <dc:creator>wylamw1</dc:creator>
    <dc:date>2021-04-23T15:58:33Z</dc:date>
    <item>
      <title>problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735315#M229067</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I'm using proc import to read in an .xls file, variables in the file are all numeric. However, for some reason, SAS decided to change one of the variable into character. I tired put function for the array of variables but wasn't successful as some variables are already in numeric format. Is there anyway to fix the problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 16:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735315#M229067</guid>
      <dc:creator>wylamw1</dc:creator>
      <dc:date>2021-04-19T16:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735329#M229077</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/369725"&gt;@wylamw1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'm using proc import to read in an .xls file, variables in the file are all numeric. However, for some reason, SAS decided to change one of the variable into character. I tired put function for the array of variables but wasn't successful as some variables are already in numeric format. Is there anyway to fix the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Save the file as CSV and write a data step to read the text file.&lt;/P&gt;
&lt;P&gt;Proc Import only examines a very small number of rows of data to set properties from XLS. So if there are no values for a variable in the first 8 rows you can get character values, if your "numeric" data contains values like "null" "na" or "." (just a decimal point with no numerals) or something else that is not actually a number then you get character values.&lt;/P&gt;
&lt;P&gt;You can write a data step, or modify one generated by Proc Import for CSV to force reading a variable as numeric.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 14:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735329#M229077</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-26T14:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735346#M229082</link>
      <description>&lt;P&gt;If you import the same XLS file the result will always be the same.&amp;nbsp; Most likely the problem you are having is that you are trying to import different files and expecting the structure generate to always be the same.&amp;nbsp; You cannot do that with PROC IMPORT from unstructured data sources like Excel files (or text files).&amp;nbsp; It will create the structure that matches the sample of data in the one file it is reading.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are probably two ways the variable could be created as character when you expected numeric.&amp;nbsp; One is that some cell in the column contains a character string.&amp;nbsp; And the other is if all of the cells the column are empty.&amp;nbsp; In that case PROC IMPORT will probably create a character variable of length 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have control over the source then don't use XLS files for your data transfer.&amp;nbsp; Use something that contain metadata to define the variables (like a SAS dataset) or use simple text files that you can write your own data step to read so that you have control over the structure of the dataset that is generated.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 19:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735346#M229082</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-19T19:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735410#M229094</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/369725"&gt;@wylamw1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'm using proc import to read in an .xls file, variables in the file are all numeric. However, for some reason, SAS decided to change one of the variable into character. I tired put function for the array of variables but wasn't successful as some variables are already in numeric format. Is there anyway to fix the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;With .xls use GUESSINGROW=MAX; in your Proc Import statement to ensure SAS scans all rows before defining the data type.&lt;/P&gt;
&lt;P&gt;IF there is in any cell under a column a character then the created SAS variable will be of type character.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 03:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735410#M229094</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-20T03:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735427#M229101</link>
      <description>&lt;P&gt;Is "guessingrows" available when reading xls-files? Isn't that option implemented for text-files only?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 06:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735427#M229101</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-04-20T06:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735450#M229111</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is "guessingrows" available when reading xls-files? Isn't that option implemented for text-files only?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You might be right. I thought it works with dbms=excel but couldn't find this anywhere documented. I haven't worked with .xls since long now and all these issues just go away with .xlsx and dbmx=xlsx&lt;/P&gt;
&lt;P&gt;If that's an adhoc job then I probably would just save your .xls as a .xlsx and go from there.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 08:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735450#M229111</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-20T08:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735551#M229144</link>
      <description>try MIXED=NO option of proc import .</description>
      <pubDate>Tue, 20 Apr 2021 13:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/735551#M229144</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-04-20T13:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736617#M229518</link>
      <description>Unfortunately I have 10+ xls files to import so it'll be great if I can make it work... I guess I'll save your suggestion as last resort. Thanks for responding!</description>
      <pubDate>Fri, 23 Apr 2021 15:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736617#M229518</guid>
      <dc:creator>wylamw1</dc:creator>
      <dc:date>2021-04-23T15:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736619#M229520</link>
      <description>The structures for all the xls files are the same. I think it's the empty cells at the beginning of some files are causing the problem.</description>
      <pubDate>Fri, 23 Apr 2021 15:58:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736619#M229520</guid>
      <dc:creator>wylamw1</dc:creator>
      <dc:date>2021-04-23T15:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736644#M229529</link>
      <description>I have the same problem even after I saved the file as .xlsx...</description>
      <pubDate>Fri, 23 Apr 2021 18:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736644#M229529</guid>
      <dc:creator>wylamw1</dc:creator>
      <dc:date>2021-04-23T18:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736645#M229530</link>
      <description>tried that too, didn't fix the problem</description>
      <pubDate>Fri, 23 Apr 2021 18:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736645#M229530</guid>
      <dc:creator>wylamw1</dc:creator>
      <dc:date>2021-04-23T18:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736909#M229682</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/369725"&gt;@wylamw1&lt;/a&gt;&amp;nbsp; - If the spreadsheets contain a top row of column names followed by data in the next row that is consistent across all rows then it is possible to use them for (mostly) reliable data exchange. The problem is most users of Excel don't appreciate this fact and muck up a simple tabular layout with reporting customisations like blank lines, spanning headers and extra comments that screw up reading the data cleanly and reliably. Add to that any old typo that Excel happily accepts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an experiment, get rid of any blank lines and reduce a spreadsheet to just one column header / column name row followed immediately by consistent data. You'd be surprised how often a rogue and hidden space or carriage return can magically change an Excel column from numeric to character. Getting a clean spreadsheet is half the battle, and as the saying goes, garbage in garbage out - the problem is Excel accepts any old garbage while SAS is much more disciplined!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 05:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736909#M229682</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-04-26T05:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: problem reading in xls file using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736914#M229685</link>
      <description>&lt;P&gt;Then follow the advice given by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;: convert the file into a proper file-format and write a data step to read it.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 06:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-reading-in-xls-file-using-proc-import/m-p/736914#M229685</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-04-26T06:31:28Z</dc:date>
    </item>
  </channel>
</rss>

