<?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 Import Excel File in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-Excel-File/m-p/966079#M376018</link>
    <description>&lt;P&gt;How do I import data from XLSX into SAS and have all the columns interpreted as text values?&lt;/P&gt;</description>
    <pubDate>Thu, 08 May 2025 15:06:12 GMT</pubDate>
    <dc:creator>_Hopper</dc:creator>
    <dc:date>2025-05-08T15:06:12Z</dc:date>
    <item>
      <title>Import Excel File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-Excel-File/m-p/966079#M376018</link>
      <description>&lt;P&gt;How do I import data from XLSX into SAS and have all the columns interpreted as text values?&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 15:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-Excel-File/m-p/966079#M376018</guid>
      <dc:creator>_Hopper</dc:creator>
      <dc:date>2025-05-08T15:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Import Excel File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-Excel-File/m-p/966082#M376019</link>
      <description>&lt;P&gt;If you are running SAS on Windows and you have a compatible version of Excel then you can use the DBSM=EXCEL setting.&amp;nbsp; That will allow you to use DBSASTYPE= dataset options.&amp;nbsp; And also I think that using the EXCEL libref engine will allow you to use pass thru SQL to query the sheet as if they are a database and do things like CAST() the values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are not and are forced to use the XLSX engine then I think the best you can do is read the sheet with GETNAMES=NO and hopefully the column headers will force SAS to make the variables character.&amp;nbsp; You can use a little code to convert the first observation into the variable names.&amp;nbsp; So you imported the sheet into a dataset named HAVE you can make a dataset named WANT with the names converted using code like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have(obs=1) out=names;
  var _all_;
run;
proc sql noprint;
  select catx('=',_name_,nliteral(col1)) into :renames separated by ' '
  from names;
quit;
data want;
  set have(firstobs=2 rename=(&amp;amp;renames));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But watch out for cells with DATE values.&amp;nbsp; Normally when those get read into a character variable you receive the raw values converted to digit strings instead of the formatted values.&amp;nbsp; To covert them into DATE values use code like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datevar= input(charvar,32.) + '31DEC1899'd ;
format datevar date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or for DATETIME values use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datetimevar= dhms(input(charvar,32.) + '31DEC1899'd,0,0,0);
format datetimevar datetime19.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 May 2025 15:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-Excel-File/m-p/966082#M376019</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-05-08T15:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Import Excel File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-Excel-File/m-p/966098#M376021</link>
      <description>&lt;P&gt;Is the the only Excel file with this structure that you will import? If not, you might consider saving the file to a text format like CSV and writing a data step to read that text file. That way you specify things like the length of the variables, which &lt;STRONG&gt;will&lt;/STRONG&gt; change if using Proc Import as well as controlling how each variable is read. Then reuse the data step by changing the name of the input file and the output data set.&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 18:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-Excel-File/m-p/966098#M376021</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-05-08T18:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Import Excel File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-Excel-File/m-p/966111#M376027</link>
      <description>&lt;P&gt;As Tom said, using DBSASTYPE= option ,&lt;/P&gt;
&lt;P&gt;but you need to list all the variable name manually ,that is very boring.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1)&lt;/P&gt;
&lt;PRE&gt;proc import datafile = "c:\temp\date.xlsx" out =have replace dbms =excel ;
dbdsopts="&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;dbsastype=&lt;/STRONG&gt;&lt;/FONT&gt;(age='numeric' &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;weight='char(20)'&lt;/STRONG&gt;&lt;/FONT&gt; weight='char(20)')";
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)&lt;/P&gt;
&lt;PRE&gt;libname x excel 'c:\temp\date.xlsx';
data have2;
set x.'date$'n(&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;dbsastype=&lt;/STRONG&gt;&lt;/FONT&gt;(age='numeric' weight='char(20)' weight='char(20)'));
run;
&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 May 2025 01:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-Excel-File/m-p/966111#M376027</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-05-09T01:21:36Z</dc:date>
    </item>
  </channel>
</rss>

