<?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: Problems with time variable when SAS import data from Excel file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506163#M135640</link>
    <description>&lt;P&gt;The Cause: Excel stores time a fraction of a day. The EXCEL&amp;nbsp;display format hides the fact that some of those fractions are repeating decimals and depending on how the value was created in Excel may have fractional values that actually include fractions of a second that&amp;nbsp;are not displayed.&lt;/P&gt;
&lt;P&gt;SAS uses number of seconds so there is a conversion issue. You may need to use a longer format to see decimal portions of time, such as best16. If the actual value is 29701.003&amp;nbsp;&amp;nbsp; then using&amp;nbsp;where timev=29701 does not match.&lt;/P&gt;
&lt;P&gt;If you want your times to display consistently to match the Excel original appearance:&lt;/P&gt;
&lt;P&gt;Save the Excel file as CSV using the Excel menu.&lt;/P&gt;
&lt;P&gt;Import the CSV.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR actually truncate the values after importing to remove any decimal bits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When the file save as is done then the value written to the CSV is actual text like 05:15:23 and the TIME informat that SAS will use will create the appropriate number of seconds without a decimal fraction.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Oct 2018 20:21:03 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-10-19T20:21:03Z</dc:date>
    <item>
      <title>Problems with time variable when SAS import data from Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506125#M135617</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem with time variables when I use "proc import" to import an excel file which contains time variables. Please see the attached excel file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My program is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT= work.Lab1&amp;nbsp;DATAFILE='test.xlsx'&amp;nbsp;DBMS=xlsx REPLACE;&amp;nbsp;getnames=yes;&amp;nbsp;format Static_test_1 Static_test_2 time8.;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data lab2; set lab1;&amp;nbsp; &amp;nbsp;timev=static_test_2;run;&lt;/P&gt;&lt;P&gt;proc print data=lab2; where timev=29701; run; /*no output printed */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I check variable timev, it does have a value of 29701, but proc print log shows there is no observation for this value. However the other values are okay. Please let me know where I did wrong. Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yangx&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 19:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506125#M135617</guid>
      <dc:creator>yangx</dc:creator>
      <dc:date>2018-10-19T19:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with time variable when SAS import data from Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506129#M135620</link>
      <description>&lt;P&gt;timev = static_test_2; is not working. Your imported variable name is Static test 2. You need to rename it to static_test_2 first.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 19:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506129#M135620</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-10-19T19:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with time variable when SAS import data from Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506134#M135623</link>
      <description>&lt;P&gt;Thanks for your reply, but it doesn't work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 19:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506134#M135623</guid>
      <dc:creator>yangx</dc:creator>
      <dc:date>2018-10-19T19:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with time variable when SAS import data from Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506143#M135630</link>
      <description>&lt;P&gt;To be more specific, not all of the values are not working, only some of time value are not working, such as '8:15:01', '9:20:48'. Don't know why some of values can be found, some of values don't equal to what you see in the dataset.&amp;nbsp; thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 19:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506143#M135630</guid>
      <dc:creator>yangx</dc:creator>
      <dc:date>2018-10-19T19:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with time variable when SAS import data from Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506144#M135631</link>
      <description>&lt;P&gt;Ok, you may want to&amp;nbsp;try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lab2; set lab1;   timev='Static test 2'n;run;

proc print data=lab2; where timev=29701; run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 19:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506144#M135631</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-10-19T19:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with time variable when SAS import data from Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506155#M135638</link>
      <description>&lt;P&gt;It works with the Enterprise Guide import code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WORK.lab1;
    LENGTH
        'Study ID'n        8
        'Static test 1'n   8
        'Static test 2'n   8 ;
    FORMAT
        'Study ID'n      BEST12.
        'Static test 1'n TIME8.
        'Static test 2'n TIME8. ;
    INFORMAT
        'Study ID'n      BEST12.
        'Static test 1'n TIME8.
        'Static test 2'n TIME8. ;
    INFILE 'C:\Users\User\AppData\Local\Temp\SEG7864\test-38d4f7e228594a3187ccc20e0a545450.txt'
        LRECL=14
        ENCODING="WLATIN1"
        TERMSTR=CRLF
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        'Study ID'n      : BEST32.
        'Static test 1'n : BEST32.
        'Static test 2'n : BEST32. ;
RUN;

data lab2; set lab1; timev='Static test 2'n;run;&lt;BR /&gt;proc print data=lab2; where timev=29701; run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 20:08:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506155#M135638</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-10-19T20:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with time variable when SAS import data from Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506163#M135640</link>
      <description>&lt;P&gt;The Cause: Excel stores time a fraction of a day. The EXCEL&amp;nbsp;display format hides the fact that some of those fractions are repeating decimals and depending on how the value was created in Excel may have fractional values that actually include fractions of a second that&amp;nbsp;are not displayed.&lt;/P&gt;
&lt;P&gt;SAS uses number of seconds so there is a conversion issue. You may need to use a longer format to see decimal portions of time, such as best16. If the actual value is 29701.003&amp;nbsp;&amp;nbsp; then using&amp;nbsp;where timev=29701 does not match.&lt;/P&gt;
&lt;P&gt;If you want your times to display consistently to match the Excel original appearance:&lt;/P&gt;
&lt;P&gt;Save the Excel file as CSV using the Excel menu.&lt;/P&gt;
&lt;P&gt;Import the CSV.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR actually truncate the values after importing to remove any decimal bits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When the file save as is done then the value written to the CSV is actual text like 05:15:23 and the TIME informat that SAS will use will create the appropriate number of seconds without a decimal fraction.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 20:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506163#M135640</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-19T20:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with time variable when SAS import data from Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506420#M135764</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your reply.&amp;nbsp; Now I understand where the problem is. I tried to use round function when I assign the time value to another variable timev, then SAS can find where timev=29701.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;xiumei&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 12:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-time-variable-when-SAS-import-data-from-Excel-file/m-p/506420#M135764</guid>
      <dc:creator>yangx</dc:creator>
      <dc:date>2018-10-22T12:57:27Z</dc:date>
    </item>
  </channel>
</rss>

