<?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 how to read .xlsx files as all character using sas 9.3? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653891#M196412</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Requirement 1 -&amp;gt; read all multiple excel files as in multiple structures as character .&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;cannot convert it to csv&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 06 Jun 2020 12:25:10 GMT</pubDate>
    <dc:creator>dennis_oz</dc:creator>
    <dc:date>2020-06-06T12:25:10Z</dc:date>
    <item>
      <title>how to read .xlsx files as all character using sas 9.3?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653891#M196412</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Requirement 1 -&amp;gt; read all multiple excel files as in multiple structures as character .&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;cannot convert it to csv&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2020 12:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653891#M196412</guid>
      <dc:creator>dennis_oz</dc:creator>
      <dc:date>2020-06-06T12:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to read .xlsx files as all character using sas 9.3?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653895#M196414</link>
      <description>&lt;P&gt;It is not possible in one pass. Any method (proc import or libname xlsx) will have its own idea about column attributes, so you will need to fix it in a follow-up step that converts all _numeric_ variables to character.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2020 13:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653895#M196414</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-06T13:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to read .xlsx files as all character using sas 9.3?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653907#M196420</link>
      <description>&lt;P&gt;The handling of reading xlsx was improved a lot in SAS 9.4 when&amp;nbsp; xlsx engine was introduced.&amp;nbsp; Do you really still have 9.3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2020 17:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653907#M196420</guid>
      <dc:creator>DavePrinsloo</dc:creator>
      <dc:date>2020-06-06T17:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to read .xlsx files as all character using sas 9.3?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653929#M196431</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19264"&gt;@dennis_oz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Requirement 1 -&amp;gt; read all multiple excel files as in multiple structures as character .&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;cannot convert it to csv&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&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;Convert to Tab delimited and use the approach would use with CSV only with TAB delimiter.&lt;/P&gt;
&lt;P&gt;(I suspect you meant "can't convert to any text file format that would actually allow this with 9.3")&lt;/P&gt;
&lt;P&gt;And where did the "cannot convert" restriction come from? If you have a lot of files of the same structure it is much easier to deal with the text formats such as CSV because you can use wildcards in file names to read multiple files with a singe data step. Which does insure that all the like variables have the same properties for length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you mean to force a Proc Import approach then there is no way you can control that length issue other than inserting a common row of values at the top of each file. Which is likely to be more work than you expect.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2020 20:16:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653929#M196431</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-06T20:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to read .xlsx files as all character using sas 9.3?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653968#M196443</link>
      <description>&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;Maybe something like this will work for you:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validmemname=extend;

libname xl excel 'C:\temp\numeric.xlsx';

data work.character;
set xl.'sheet1$'n(dbsastype=('a'='char(10)'
                             'b'='char(10)'
                             'c'='char(10)'
                             'd'='char(10)')
                  );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;The EXCEL engine is supported only on Windows, and the bitness of SAS must match the bitness of Windows.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;Vince DelGobbo&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;SAS R&amp;amp;D&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2020 22:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/653968#M196443</guid>
      <dc:creator>Vince_SAS</dc:creator>
      <dc:date>2020-06-06T22:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to read .xlsx files as all character using sas 9.3?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/654094#M196498</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19264"&gt;@dennis_oz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Requirement 1 -&amp;gt; read all multiple excel files as in multiple structures as character .&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;cannot convert it to csv&lt;/LI&gt;
&lt;/OL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Except for the approach&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13635"&gt;@Vince_SAS&lt;/a&gt;&amp;nbsp;proposes - which I'm not sure is already available in SAS 9.3 - there is no direct way to read all source data into character variables only.&lt;/P&gt;
&lt;P&gt;I believe if reading from an Excel source SAS will always attach a format to the created variables. If so then you could try if code as below does what you're after.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro convertAllVarsToChar(inds, outds=);
  %let inds=%upcase(&amp;amp;inds);
  %if &amp;amp;outds= %then %let outds=&amp;amp;inds;
  %local lib tbl;
  %let lib=%scan(WORK.&amp;amp;inds,-2,.);
  %let tbl=%scan(&amp;amp;inds,1,.);

  proc sql;
    create table want_meta as
    select *
    from dictionary.columns
    where libname="&amp;amp;lib" and memname="&amp;amp;tbl"
    order by varnum
    ;
  quit;

  filename codegen temp;
  data _null_;
  /*  file print;*/
    file codegen;
    set want_meta end=last;

    length nm_in nm_out $35;
    nm_in =cats("'",name,"'n");
    nm_out=cats("'_",substrn(name,1,31),"'n");

    if _n_=1 then
      do;
        put 
          "data &amp;amp;outds;" /
          @3 "set &amp;amp;inds;"
          ;
      end;

    if type='num' then
      do;
        if format='BEST.' then format='BEST16.';
        put @3 nm_out '= put(' nm_in ',' format ');';
      end;
    else
      put @3 nm_out '=' nm_in ';';
    put
      @3 'drop ' nm_in ';' /
      @3 'rename ' nm_out '=' nm_in ';' 
      ;
    if last then
      put 'run;';
  run;

  %include codegen / source2;
  filename codegen clear;
%mend;

proc import 
  datafile='~/test/test.xlsx'
  out=want
  dbms=xlsx
  replace
  ;
run;

title 'Before Conversion';
proc contents data=want;
run;

%convertAllVarsToChar(want);

title 'After Conversion';
proc contents data=want;
run;
proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 03:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-xlsx-files-as-all-character-using-sas-9-3/m-p/654094#M196498</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-08T03:12:27Z</dc:date>
    </item>
  </channel>
</rss>

