<?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: How to handle null for column date from excel to load to dataset in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185827#M3803</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;at &lt;A __default_attr="119192" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Are you sure that there won't be a type mismatch during execution in cases where the metadata table expects a numeric variable (a SAS date) but the whole source column is Null?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree that conversion to cvs is overhead - it's not a lot of extra coding though and you can implement with a rather simple user transformation with path, workbook and sheet as prompt.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Jan 2014 09:51:14 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2014-01-08T09:51:14Z</dc:date>
    <item>
      <title>How to handle null for column date from excel to load to dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185823#M3799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new with SAS DI. I want to extract the data from excel to sas dataset. I am using user written code to extract data from excel to sas dataset.&lt;/P&gt;&lt;P&gt;I create the table and set format DATETIME16. for column date. However, I face a problem for date column form excel null and it become error and fail to load the data.&lt;/P&gt;&lt;P&gt;Anyone can help me on this problem?..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Noomie&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jan 2014 03:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185823#M3799</guid>
      <dc:creator>Naomi</dc:creator>
      <dc:date>2014-01-02T03:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle null for column date from excel to load to dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185824#M3800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you please send a sample of a couple of obs and the code you have written for people to understand and give you a precise solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Naveen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jan 2014 04:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185824#M3800</guid>
      <dc:creator>NaveenSrinivasan</dc:creator>
      <dc:date>2014-01-02T04:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle null for column date from excel to load to dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185825#M3801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't give us enough information so below is based on some assumptions. If I understand your problem then you're using Proc Import and in cases where all rows for the datetime column in your Excel source are missing you end up with a character variable. As to my knowledge there is no way to tell Proc Import to apply a specific variable type for a source column. It's based on scanning the source data - and if it's all missing then Proc Import defaults to a character variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Excel is just a bad source for data integration and should be avoided. But I know that it's sometimes not possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the Excel source is rectangular then you could try and register it as metadata table object. I've done this in the past with mixed results. &lt;A href="http://support.sas.com/documentation/cdl/en/etlug/65016/HTML/default/viewer.htm#n1u5wrckqyafv0n11skke9w5xyui.htm" title="http://support.sas.com/documentation/cdl/en/etlug/65016/HTML/default/viewer.htm#n1u5wrckqyafv0n11skke9w5xyui.htm"&gt;SAS(R) Data Integration Studio 4.4: User's Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another way which I've already used is to first read the Excel source using Proc Import, then write the resulting table as text delimited file to disk and then define a External File metadata object for this csv. After that it's "out-of-the-box" ETL.&lt;/P&gt;&lt;P&gt;Such an approach adds some I/0 but it let's you much better control how you read the data for further processing.&lt;/P&gt;&lt;P&gt;In the past my thinking for such an approach was also that may be somewhere in the future I will be getting a "reasonable" extracts like a csv. So what I've done is to implement a separate DI job which only reads the Excel and writes it to disk as csv. The next job then reads this csv using a External File Metadata object. And if once in the future data is directly provided as csv one would only need to turn of the first conversion job.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below a code example which uses such an approach. The csv gets written to a temporary file and no external file metadata object is used. You might decide to modify the code and split it up into 2 jobs using above approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* create target table */&lt;BR /&gt;data target;&lt;BR /&gt;&amp;nbsp; attrib charvar length=$20 datetimevar length=8 informat=datetime. format=datetime16. numvar length=8;&lt;BR /&gt;&amp;nbsp; charvar='target';&lt;BR /&gt;&amp;nbsp; datetimevar=datetime();&lt;BR /&gt;&amp;nbsp; numvar=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* create table as it could look like after Proc Import with all values in datetime column missing */&lt;BR /&gt;data after_import_from_excel;&lt;BR /&gt;&amp;nbsp; attrib charvar length=$20 datetimevar length=$10 numvar length=8;&lt;BR /&gt;&amp;nbsp; charvar='source,test';&lt;BR /&gt;&amp;nbsp; call missing(datetimevar);&lt;BR /&gt;&amp;nbsp; numvar=2;&lt;BR /&gt;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* create temporary file */&lt;BR /&gt;filename csvtmp temp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* write imported data to temporary file as csv */&lt;BR /&gt;ods csv file=csvtmp;&lt;/P&gt;&lt;P&gt;proc print data=after_import_from_excel noobs;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;ods csv close;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* import csv with variable types as required for loading into target */&lt;BR /&gt;data source;&lt;BR /&gt;&amp;nbsp; attrib charvar length=$20 datetimevar length=8 informat=datetime. format=datetime16. numvar length=8;&lt;BR /&gt;&amp;nbsp; infile csvtmp dsd dlm="," firstobs=2 truncover;&lt;BR /&gt;&amp;nbsp; input charvar datetimevar numvar;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* release temporary file */&lt;BR /&gt;filename csvtmp clear;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* load source into target */&lt;BR /&gt;proc append base=target data=source force nowarn;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Jan 2014 03:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185825#M3801</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-01-04T03:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle null for column date from excel to load to dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185826#M3802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Totally agree with Patrick on usage of Excel filen in a data warehouse environment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having that said, I also think that doing a rond robin using temporary CSV-files seems un-necessary complicated, since it add some substantial user written code, espacially if there are several/many Excel-files to ne imported.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even with it flaws, using meta data objects for Excel files should be seen as best practice. The main negative side of this is that you need to register a database server and a schema for each Excel file (as I recall).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Still, if we assume that PROC IMPORT is used in Naomis user written code, ther eshouls be ways to make this work (depending in the nature of the error - very little information here). Have you tried adjusting the MIXED option and the TypeGuessRows registry value?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jan 2014 09:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185826#M3802</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-01-08T09:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle null for column date from excel to load to dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185827#M3803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;at &lt;A __default_attr="119192" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Are you sure that there won't be a type mismatch during execution in cases where the metadata table expects a numeric variable (a SAS date) but the whole source column is Null?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree that conversion to cvs is overhead - it's not a lot of extra coding though and you can implement with a rather simple user transformation with path, workbook and sheet as prompt.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jan 2014 09:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-handle-null-for-column-date-from-excel-to-load-to-dataset/m-p/185827#M3803</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-01-08T09:51:14Z</dc:date>
    </item>
  </channel>
</rss>

