<?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: Import empty column as date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-empty-column-as-date/m-p/825865#M326195</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256609"&gt;@Taliah&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As I need to import this as Excel&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P style="font-weight: 400;"&gt;You don't. Any sheet in a .xlsx file can be saved as csv, and you don't even need Excel to do it. Other software like LibreOffice can even do it from the commandline.&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;In all my professional SAS life, I never imported Excel files in production jobs. Data was always transported via text files, either csv (comma- or semicolon-separated) or with fixed column lengths. If I received Excel files where the data had to align with existing datasets, I also saved the data to text files and read those with data steps, to avoid all the hassle.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jul 2022 09:03:50 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-07-28T09:03:50Z</dc:date>
    <item>
      <title>Import empty column as date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-empty-column-as-date/m-p/825844#M326181</link>
      <description>&lt;P&gt;I am using the following code to import an Excel file.&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;import&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;datafile="&amp;amp;dir.fileA"&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DBMS=xlsx&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;out=PARAM&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;replace;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;getnames=YES;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;SHEET='PARAM';&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;format&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;EndDate&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ddmmyy10.;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;column&amp;nbsp;EndDate is sometimes empty. I need to have it in the sas dataset as date format. when it is empty it is imported as Char and of course I get the following error -&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&lt;SPAN&gt;ERROR: You are trying to use the numeric format DDMMYY with the character variable EndDate&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;Is there a way to import it as date that will work even when the column is empty?&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;Thank you.&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 06:33:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-empty-column-as-date/m-p/825844#M326181</guid>
      <dc:creator>Taliah</dc:creator>
      <dc:date>2022-07-28T06:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Import empty column as date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-empty-column-as-date/m-p/825845#M326182</link>
      <description>&lt;P&gt;Sorry, but this is not possible, because proc import has to rely on the content of the excel file to define types and lengths. So, if there is nothing in a column proc import (and libname) can't be persuaded to set the type of the column to numeric an apply a date format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The goods news: the issue is caused by using Excel as data source. If you switch to csv and write the importing step yourself, you won't have problems like this at all.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 06:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-empty-column-as-date/m-p/825845#M326182</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-07-28T06:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Import empty column as date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-empty-column-as-date/m-p/825848#M326185</link>
      <description>&lt;P&gt;Thank you. As I need to import this as Excel, and need this col to bo a date col, I ended up adding the following code to change that col to date when it is empty. It seems to work.&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;PARAM_1(drop&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;= EndDate2);&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;format&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;EndDate ddmmyy10.;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;set&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;PARAM (rename=(EndDate=EndDate2));&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;EndDate2 eq&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;""&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;then&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;EndDate=input(EndDate2,ddmmyy10.);&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;EndDate=&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;EndDate2;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG style="font-family: inherit;"&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 07:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-empty-column-as-date/m-p/825848#M326185</guid>
      <dc:creator>Taliah</dc:creator>
      <dc:date>2022-07-28T07:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: Import empty column as date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-empty-column-as-date/m-p/825865#M326195</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256609"&gt;@Taliah&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As I need to import this as Excel&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P style="font-weight: 400;"&gt;You don't. Any sheet in a .xlsx file can be saved as csv, and you don't even need Excel to do it. Other software like LibreOffice can even do it from the commandline.&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;In all my professional SAS life, I never imported Excel files in production jobs. Data was always transported via text files, either csv (comma- or semicolon-separated) or with fixed column lengths. If I received Excel files where the data had to align with existing datasets, I also saved the data to text files and read those with data steps, to avoid all the hassle.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 09:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-empty-column-as-date/m-p/825865#M326195</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-28T09:03:50Z</dc:date>
    </item>
  </channel>
</rss>

