<?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 SAS DateTime calcuations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-DateTime-calcuations/m-p/617303#M180865</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a difficulty with SAS dates. I am trying to find the number of observations between two SAS datetime values. I have a dataset with a column datetime1 and column datetime2 and I want to see how many observations are within an hour in these two columns. For e.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Datetime1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; DateTime2&lt;/P&gt;&lt;P&gt;07/13/2017:15:04 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07/13/2017:16:04&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to know how many observations are between these two datetimes. I have this statement in SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;if input(Datetime1, mdyampm.) &amp;gt; input (Datetime2, mdyampm.) and input (datetime1, mdyampm.) &amp;lt; input(datetime2, mdyampm.)+3600;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jan 2020 20:24:22 GMT</pubDate>
    <dc:creator>Malathi13</dc:creator>
    <dc:date>2020-01-14T20:24:22Z</dc:date>
    <item>
      <title>SAS DateTime calcuations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DateTime-calcuations/m-p/617303#M180865</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a difficulty with SAS dates. I am trying to find the number of observations between two SAS datetime values. I have a dataset with a column datetime1 and column datetime2 and I want to see how many observations are within an hour in these two columns. For e.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Datetime1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; DateTime2&lt;/P&gt;&lt;P&gt;07/13/2017:15:04 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07/13/2017:16:04&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to know how many observations are between these two datetimes. I have this statement in SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;if input(Datetime1, mdyampm.) &amp;gt; input (Datetime2, mdyampm.) and input (datetime1, mdyampm.) &amp;lt; input(datetime2, mdyampm.)+3600;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 20:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DateTime-calcuations/m-p/617303#M180865</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2020-01-14T20:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DateTime calcuations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DateTime-calcuations/m-p/617316#M180873</link>
      <description>&lt;P&gt;What happens when you run the code? Is there an error in the LOG? (if so, please show us the log, the code AND the error messages) Or do you get the wrong answer?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, are datetime1 and datetime2 character variables or numeric variables?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 21:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DateTime-calcuations/m-p/617316#M180873</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-14T21:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DateTime calcuations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DateTime-calcuations/m-p/617319#M180875</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm getting an error when I run the code:&lt;/P&gt;&lt;P&gt;NOTE: Invalid numeric data, datetime1='9/12/2019 22:13' , at line 478 column 23.&lt;BR /&gt;WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used this code:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATA onehour2; SET matched2;&lt;BR /&gt;IF INPUT(datetime2, mdyampm.) &amp;gt; INPUT(&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;datetime2&lt;/SPAN&gt;, mdyampm.)&lt;BR /&gt;and&lt;BR /&gt;INPUT(&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;datetime2&lt;/SPAN&gt;, mdyampm.) &amp;lt; INPUT(&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;datetime2&lt;/SPAN&gt;, mdyampm.) + 3600;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Datetime1 and Datetime2 are character variables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 21:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DateTime-calcuations/m-p/617319#M180875</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2020-01-14T21:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DateTime calcuations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DateTime-calcuations/m-p/617340#M180889</link>
      <description>&lt;P&gt;I specifically asked to see the LOG showing both the code and the error messages. Please provide that information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I also asked about what type of variable these datetimes are, numeric or character. Please provide that information.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 22:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DateTime-calcuations/m-p/617340#M180889</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-14T22:46:29Z</dc:date>
    </item>
  </channel>
</rss>

