<?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: Sort by datetime in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sort-by-datetime/m-p/835362#M330264</link>
    <description>&lt;P&gt;try this input statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input datetime:datetime.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 27 Sep 2022 05:05:15 GMT</pubDate>
    <dc:creator>japelin</dc:creator>
    <dc:date>2022-09-27T05:05:15Z</dc:date>
    <item>
      <title>Sort by datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-by-datetime/m-p/835359#M330261</link>
      <description>&lt;P&gt;Sorry, this code doesnt work, but trying to sort the datetime variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input datetime;&lt;BR /&gt;format datetime datetime.;&lt;BR /&gt;infile datalines missover;&lt;BR /&gt;datalines;&lt;BR /&gt;01AUG2022:11:51:35&lt;BR /&gt;22JUL2019:11:41:32&lt;BR /&gt;22JUL2019:11:50:32&lt;BR /&gt;25FEB2015:16:05:39&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 04:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-by-datetime/m-p/835359#M330261</guid>
      <dc:creator>ywon111</dc:creator>
      <dc:date>2022-09-27T04:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-by-datetime/m-p/835360#M330262</link>
      <description>The usual proc sort doesn't work and it just sorted it by date, didn't take in consideration of the time.</description>
      <pubDate>Tue, 27 Sep 2022 04:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-by-datetime/m-p/835360#M330262</guid>
      <dc:creator>ywon111</dc:creator>
      <dc:date>2022-09-27T04:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-by-datetime/m-p/835362#M330264</link>
      <description>&lt;P&gt;try this input statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input datetime:datetime.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Sep 2022 05:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-by-datetime/m-p/835362#M330264</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-09-27T05:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-by-datetime/m-p/835375#M330270</link>
      <description>&lt;P&gt;That data step as shown will not generate any output data values to sort. Without a proper informat specified the input statement tells SAS to read the values as basic numeric values. But the : occurs as part of the value so is treated as not valid as a number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;586  data have;
587  input datetime;
588  format datetime datetime.;
589  infile datalines missover;
590  datalines;

NOTE: Invalid data for datetime in line 591 1-18.
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--
591        01AUG2022:11:51:35
datetime=. _ERROR_=1 _N_=1
NOTE: Invalid data for datetime in line 592 1-18.
592        22JUL2019:11:41:32
datetime=. _ERROR_=1 _N_=2
NOTE: Invalid data for datetime in line 593 1-18.
593        22JUL2019:11:50:32
datetime=. _ERROR_=1 _N_=3
NOTE: Invalid data for datetime in line 594 1-18.
594        25FEB2015:16:05:39
datetime=. _ERROR_=1 _N_=4
NOTE: The data set WORK.HAVE has 4 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;If you want the year to appear with 4 digits you need to set a longer than default width for the Datetime format.&lt;/P&gt;
&lt;PRE&gt;data have;
input datetime :datetime.;
format datetime datetime19.;
infile datalines missover;
datalines;
01AUG2022:11:51:35
22JUL2019:11:41:32
22JUL2019:11:50:32
25FEB2015:16:05:39
;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Sep 2022 06:48:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-by-datetime/m-p/835375#M330270</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-27T06:48:47Z</dc:date>
    </item>
  </channel>
</rss>

