<?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 from Excel Problem: Data step vs Proc Import in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272144#M18882</link>
    <description>&lt;P&gt;I'm importing a dataset from an Excel file&amp;nbsp;that contains a date column. In Excel, this column is properly a data (i.e., it's a date serial) formatted as a short date (m/d/yyyy). &amp;nbsp;In EG, I'm using the Import Data task to, well, import the data. &amp;nbsp;On the Define Field Attributes screen, I have the following settings for the date column:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Type: Date&lt;/LI&gt;
&lt;LI&gt;Source Informat: ANYDTDTE9.&lt;/LI&gt;
&lt;LI&gt;Len.: 8&lt;/LI&gt;
&lt;LI&gt;Output Format: Date9.&lt;/LI&gt;
&lt;LI&gt;Output Informat: ANYDTDTE9.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Now here's the confusing part: on the Advanced Options page, if I select "Import the data using SAS/Access Interface to PC Files whenever possible" (yes, I have this component), the dates all import as 01Jan1960 (and when formatted as a number, they are all 0). &amp;nbsp;However, if I uncheck that box, the dates import just fine. &amp;nbsp;For reference, the SAS code generated by checking the box, or leaving it blank are below. &amp;nbsp;Does anyone know why simply checking that box would cause it to not import correctly, despite the same import settings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the code generated by the import data task for the SAS/ACCESS version&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT
        DATAFILE="I:\SASWork\_TD6320_CMHPRDSASMET01_\#LN00957.xlsx"
        OUT=WORK.VACATION_SWAPS_TO_LOAD2
        REPLACE
        DBMS=EXCEL;
    RANGE="Sheet1$A1:C101";
    GETNAMES=YES;
RUN;

/* --------------------------------------------------------------------
   This DATA step is used to both modify the attributes of fields
   imported by PROC IMPORT and perform any field type specific
   conversions needed.
   -------------------------------------------------------------------- */

DATA WORK.VACATION_SWAPS_TO_LOAD2;
    LENGTH
        FLEET            $ 32
        RANK             $ 3
        WEEK               8 ;
    SET WORK.VACATION_SWAPS_TO_LOAD2;
    FORMAT
        FLEET            $CHAR32.
        RANK             $CHAR3.
        WEEK             DATE9. ;
    INFORMAT
        FLEET            $CHAR32.
        RANK             $CHAR3.
        WEEK             ANYDTDTE9. ;
    /* ----------------------------------------------------------------
       For fields that were imported as datetime values but need to be
       treated as date or time values, a conversion is required in
       order to extract the date or time portion from the datetime
       value.
       ---------------------------------------------------------------- */
    WEEK = DATEPART(WEEK);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;...And here's the code generated by the import data task for the non-SAS/ACCESS version&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* --------------------------------------------------------------------
   This DATA step reads the data values from a temporary text file
   created by the Import Data wizard. The values within the temporary
   text file were extracted from the Excel source file.
   -------------------------------------------------------------------- */

DATA WORK.VACATION_SWAPS_TO_LOAD;
    LENGTH
        FLEET            $ 32
        RANK             $ 3
        WEEK               8 ;
    FORMAT
        FLEET            $CHAR32.
        RANK             $CHAR3.
        WEEK             DATE9. ;
    INFORMAT
        FLEET            $CHAR32.
        RANK             $CHAR3.
        WEEK             ANYDTDTE9. ;
    INFILE 'I:\SASWork\_TD6320_CMHPRDSASMET01_\#LN00954'
        LRECL=27
        ENCODING="WLATIN1"
        TERMSTR=CRLF
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        FLEET            : $CHAR32.
        RANK             : $CHAR3.
        WEEK             : ANYDTDTE9. ;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 May 2016 20:37:38 GMT</pubDate>
    <dc:creator>sdennett</dc:creator>
    <dc:date>2016-05-20T20:37:38Z</dc:date>
    <item>
      <title>Import from Excel Problem: Data step vs Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272144#M18882</link>
      <description>&lt;P&gt;I'm importing a dataset from an Excel file&amp;nbsp;that contains a date column. In Excel, this column is properly a data (i.e., it's a date serial) formatted as a short date (m/d/yyyy). &amp;nbsp;In EG, I'm using the Import Data task to, well, import the data. &amp;nbsp;On the Define Field Attributes screen, I have the following settings for the date column:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Type: Date&lt;/LI&gt;
&lt;LI&gt;Source Informat: ANYDTDTE9.&lt;/LI&gt;
&lt;LI&gt;Len.: 8&lt;/LI&gt;
&lt;LI&gt;Output Format: Date9.&lt;/LI&gt;
&lt;LI&gt;Output Informat: ANYDTDTE9.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Now here's the confusing part: on the Advanced Options page, if I select "Import the data using SAS/Access Interface to PC Files whenever possible" (yes, I have this component), the dates all import as 01Jan1960 (and when formatted as a number, they are all 0). &amp;nbsp;However, if I uncheck that box, the dates import just fine. &amp;nbsp;For reference, the SAS code generated by checking the box, or leaving it blank are below. &amp;nbsp;Does anyone know why simply checking that box would cause it to not import correctly, despite the same import settings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the code generated by the import data task for the SAS/ACCESS version&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT
        DATAFILE="I:\SASWork\_TD6320_CMHPRDSASMET01_\#LN00957.xlsx"
        OUT=WORK.VACATION_SWAPS_TO_LOAD2
        REPLACE
        DBMS=EXCEL;
    RANGE="Sheet1$A1:C101";
    GETNAMES=YES;
RUN;

/* --------------------------------------------------------------------
   This DATA step is used to both modify the attributes of fields
   imported by PROC IMPORT and perform any field type specific
   conversions needed.
   -------------------------------------------------------------------- */

DATA WORK.VACATION_SWAPS_TO_LOAD2;
    LENGTH
        FLEET            $ 32
        RANK             $ 3
        WEEK               8 ;
    SET WORK.VACATION_SWAPS_TO_LOAD2;
    FORMAT
        FLEET            $CHAR32.
        RANK             $CHAR3.
        WEEK             DATE9. ;
    INFORMAT
        FLEET            $CHAR32.
        RANK             $CHAR3.
        WEEK             ANYDTDTE9. ;
    /* ----------------------------------------------------------------
       For fields that were imported as datetime values but need to be
       treated as date or time values, a conversion is required in
       order to extract the date or time portion from the datetime
       value.
       ---------------------------------------------------------------- */
    WEEK = DATEPART(WEEK);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;...And here's the code generated by the import data task for the non-SAS/ACCESS version&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* --------------------------------------------------------------------
   This DATA step reads the data values from a temporary text file
   created by the Import Data wizard. The values within the temporary
   text file were extracted from the Excel source file.
   -------------------------------------------------------------------- */

DATA WORK.VACATION_SWAPS_TO_LOAD;
    LENGTH
        FLEET            $ 32
        RANK             $ 3
        WEEK               8 ;
    FORMAT
        FLEET            $CHAR32.
        RANK             $CHAR3.
        WEEK             DATE9. ;
    INFORMAT
        FLEET            $CHAR32.
        RANK             $CHAR3.
        WEEK             ANYDTDTE9. ;
    INFILE 'I:\SASWork\_TD6320_CMHPRDSASMET01_\#LN00954'
        LRECL=27
        ENCODING="WLATIN1"
        TERMSTR=CRLF
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        FLEET            : $CHAR32.
        RANK             : $CHAR3.
        WEEK             : ANYDTDTE9. ;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 20:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272144#M18882</guid>
      <dc:creator>sdennett</dc:creator>
      <dc:date>2016-05-20T20:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Import from Excel Problem: Data step vs Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272164#M18883</link>
      <description>&lt;P&gt;This code destroyed in actual imported dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WORK.VACATION_SWAPS_TO_LOAD2;
    LENGTH
        FLEET            $ 32
        RANK             $ 3
        WEEK               8 ;
    SET WORK.VACATION_SWAPS_TO_LOAD2;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So you are not looking at the data as imported.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please rerun the Proc import and then run Proc Contents and show the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect that your treatment of an original DATE value as datetime reduced the values so much. Since a Date value in Excel of 1/1/2015 would be 42005 and you treated it as a Datetime (which is seconds) then that became day 0 which is 1Jan1960.&lt;/P&gt;
&lt;P&gt;See this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data junk;
   x=42005;
   put x= datetime20.;
   y = datepart(42005);
   put y;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I suspect the actual Import created a DATE value that you may have assumed was a datetime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 20:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272164#M18883</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-20T20:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Import from Excel Problem: Data step vs Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272171#M18884</link>
      <description>&lt;P&gt;It looks like you are right, but that goes a bit beyond my question. &amp;nbsp;To be clear, I did not write any of the code above, it is all autogenerated by EG, and the only difference between the two is due to the SAS/ACCESS checkbox being checked or not. &amp;nbsp;I'm more interested in figuring out if what I'm expecting from checking that box is different from what I should be expecting to happen.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 21:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272171#M18884</guid>
      <dc:creator>sdennett</dc:creator>
      <dc:date>2016-05-20T21:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: Import from Excel Problem: Data step vs Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272185#M18886</link>
      <description>&lt;P&gt;Please post the proc contents after the import. The comments you say about "all the dates are " indicate to me that you did not look at the imported data before manipulating it.&lt;/P&gt;
&lt;P&gt;Or import it to one dataset using the proc import and then use the datastep to read the file&amp;nbsp;into a&amp;nbsp;differently named dataset&amp;nbsp;and then run PROC COMPARE on the two before doing any manipulation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not say how the TEXT file was created. It is possible that the step creating the file manipulates values.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 21:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272185#M18886</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-20T21:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Import from Excel Problem: Data step vs Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272229#M18895</link>
      <description>&lt;P&gt;Excel files are among the worst types of data sources I ever came across in my time as a DWH admin/developer.&lt;/P&gt;
&lt;P&gt;You are much better off saving the data to a textual format and importing that.&lt;/P&gt;
&lt;P&gt;Why the MS-supplied Data Access Objects treats Excel dates as datetime values when exporting is a secret that probably will never be lifted.&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2016 06:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272229#M18895</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-05-21T06:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Import from Excel Problem: Data step vs Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272236#M18896</link>
      <description>&lt;P&gt;Judging from the first few responses, I think I need to restate my problem/question. &amp;nbsp;I am not asking how to fix the code to get data into SAS correctly (which, again, is wholly autogenerated by EG); I can get the data in just fine so long as I don't use SAS/ACCESS. &amp;nbsp;I'm also not asking whether I should be using Excel or not. &amp;nbsp;For various reasons, Excel is the preferred method here for entering the data. In fact, I would probably prefer to use a CSV here, but as I have a method that can import the Excel data fine, and Excel is the preferred method for this project, it's staying in Excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The question I am asking is this&lt;/STRONG&gt;: &amp;nbsp;Why does Enterprise Guide's (v7.1) Import Data task, when given identical input parameters, import data differently when using SAS/ACCESS or not? &amp;nbsp;Is this expected behavior? &amp;nbsp;If I use SAS/ACCESS do I need to use different input parameters?&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2016 11:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272236#M18896</guid>
      <dc:creator>sdennett</dc:creator>
      <dc:date>2016-05-21T11:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Import from Excel Problem: Data step vs Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272242#M18897</link>
      <description>&lt;P&gt;Why? &amp;nbsp;Because you are using two different methods.&lt;/P&gt;
&lt;P&gt;If you ask it to use SAS/Access then it will use PROC IMPORT to read the file. Otherwise Enterprise Guide will convert the Excel file to a text file, copy the text file to your SAS server and write a data step to read it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are always going to use Enterprise Guide and the source file is available to use on the machine where Enterprise Guide is running then I would recommend using that tool as I think you will have better control over the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using PROC IMPORT to convert a file requires it to guess at what the file contains.&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2016 14:39:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-from-Excel-Problem-Data-step-vs-Proc-Import/m-p/272242#M18897</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-05-21T14:39:24Z</dc:date>
    </item>
  </channel>
</rss>

