<?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: Libname XLSX reading in date var that is almost always missing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839800#M332014</link>
    <description>&lt;P&gt;Try the DBSASTYPE option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set xl.mytab (dbsastype=(MyExcelDate = 'date'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 20 Oct 2022 21:29:04 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2022-10-20T21:29:04Z</dc:date>
    <item>
      <title>Libname XLSX reading in date var that is almost always missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839798#M332012</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am reading in a bunch of Excel files using the XLSX libname:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each Excel file, the macro does this:&lt;/P&gt;
&lt;P&gt;libname xl xlsx "mypath\file1.xlsx";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set xl.mytab;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is that there is a date variable on each Excel file. This is almost always missing so SAS is interpreting it as a character variable. I tried adding format and length statements, which causes an error message because there is a mismatch between what I'm telling SAS the variable is and the decision SAS has made by checking the values in the Excel file. Specifiically: Variable has been defined as both character and numeric&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are there any workarounds for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 21:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839798#M332012</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2022-10-20T21:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: Libname XLSX reading in date var that is almost always missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839799#M332013</link>
      <description>Not really, except to check the type and convert it after the fact.</description>
      <pubDate>Thu, 20 Oct 2022 21:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839799#M332013</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-20T21:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Libname XLSX reading in date var that is almost always missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839800#M332014</link>
      <description>&lt;P&gt;Try the DBSASTYPE option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set xl.mytab (dbsastype=(MyExcelDate = 'date'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Oct 2022 21:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839800#M332014</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-10-20T21:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Libname XLSX reading in date var that is almost always missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839801#M332015</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Try the DBSASTYPE option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set xl.mytab (dbsastype=(MyExcelDate = 'date'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Last time I checked, dbsastype was not supported by the XLSX engine, unfortunately.&amp;nbsp; I'm not sure I checked in M7.&amp;nbsp; Would be thrilled if it's there.&amp;nbsp; Or maybe it will be a gift in M8....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37814"&gt;@Walternate&lt;/a&gt;&amp;nbsp; please consider upvoting this ballot item requesting SAS add support for the dbsastype option to the XLSX engine:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/Add-DBSASTYPE-or-similar-option-to-XLSX-engine-to-force-variable/idi-p/453938" target="_blank"&gt;https://communities.sas.com/t5/SASware-Ballot-Ideas/Add-DBSASTYPE-or-similar-option-to-XLSX-engine-to-force-variable/idi-p/453938&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See also this related thread, where people shared workarounds, for example changing to the PCFILES engine or another engine which does support dbsastype:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Reading-XLSX-file-and-force-SAS-column-types/m-p/430934#M106536" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Reading-XLSX-file-and-force-SAS-column-types/m-p/430934#M106536&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm a big fan of the XLSX engine.&amp;nbsp; The fact that dbsastype is unsupported is my only complaint.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 21:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839801#M332015</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-10-20T21:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Libname XLSX reading in date var that is almost always missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839814#M332021</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;- Thanks for pointing that out. Maybe it works for the EXCEL engine? I don't have M7 to try.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 22:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839814#M332021</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-10-20T22:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Libname XLSX reading in date var that is almost always missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839854#M332047</link>
      <description>&lt;P&gt;The usual advice:&lt;/P&gt;
&lt;P&gt;save the data to a sensible file format (e.g. csv) and read it with a data step, where &lt;EM&gt;you&lt;/EM&gt; have full control.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 06:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-XLSX-reading-in-date-var-that-is-almost-always-missing/m-p/839854#M332047</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-10-21T06:48:08Z</dc:date>
    </item>
  </channel>
</rss>

