<?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: Hour Function from datetime not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810778#M319751</link>
    <description>&lt;P&gt;Hi Kurt - you were spot on!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had the table open but a piece of my code messed up the dataset. I re-imported, ran the code as is and voila!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Sat, 30 Apr 2022 07:31:11 GMT</pubDate>
    <dc:creator>programeerSAS</dc:creator>
    <dc:date>2022-04-30T07:31:11Z</dc:date>
    <item>
      <title>Hour Function from datetime not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810566#M319635</link>
      <description>&lt;P&gt;Running this code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data electric.blt_hours;&lt;BR /&gt;set electric.blt;&lt;/P&gt;&lt;P&gt;Hours = hour(TransDateTime) ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the property of the datetime field that was read in using proc import with guessing rows option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="programeerSAS_0-1651226694071.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70978i9642BB3FDA155F75/image-size/medium?v=v2&amp;amp;px=400" role="button" title="programeerSAS_0-1651226694071.png" alt="programeerSAS_0-1651226694071.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Log states:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;/DIV&gt;&lt;DIV class=""&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;/DIV&gt;&lt;DIV class=""&gt;1 at 72:9&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: There were 1 observations read from the data set ELECTRIC.BLT.&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: The data set ELECTRIC.BLT_HOURS has 1 observations and 4 variables.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Not sure why the hour cannot be read if it is a numeric SAS date value it is reading from....&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 10:08:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810566#M319635</guid>
      <dc:creator>programeerSAS</dc:creator>
      <dc:date>2022-04-29T10:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Hour Function from datetime not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810568#M319636</link>
      <description>&lt;P&gt;Your dataset has only one observation, and in this one observation the variable in question contains a missing value. From a missing value, only a missing value can result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299508"&gt;@programeerSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Running this code :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data electric.blt_hours;&lt;BR /&gt;set electric.blt;&lt;/P&gt;
&lt;P&gt;Hours = hour(TransDateTime) ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the property of the datetime field that was read in using proc import with guessing rows option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="programeerSAS_0-1651226694071.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70978i9642BB3FDA155F75/image-size/medium?v=v2&amp;amp;px=400" role="button" title="programeerSAS_0-1651226694071.png" alt="programeerSAS_0-1651226694071.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Log states:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=""&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;/DIV&gt;
&lt;DIV class=""&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;/DIV&gt;
&lt;DIV class=""&gt;1 at 72:9&lt;/DIV&gt;
&lt;DIV class=""&gt;NOTE: There were 1 observations read from the data set ELECTRIC.BLT.&lt;/DIV&gt;
&lt;DIV class=""&gt;NOTE: The data set ELECTRIC.BLT_HOURS has 1 observations and 4 variables.&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;Not sure why the hour cannot be read if it is a numeric SAS date value it is reading from....&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 10:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810568#M319636</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-29T10:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Hour Function from datetime not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810569#M319637</link>
      <description>&lt;P&gt;PS from a valid datetime value, the HOUR function returns the hour as documented:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
now = datetime();
hours = hour(now);
format now e8601dt19.;
put now= hours=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 69         data _null_;
 70         now = datetime();
 71         hours = hour(now);
 72         format now e8601dt19.;
 73         put now= hours=;
 74         run;
 
 now=2022-04-29T12:18:40 hours=12
&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Apr 2022 10:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810569#M319637</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-29T10:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Hour Function from datetime not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810581#M319643</link>
      <description>Hi Kurt&lt;BR /&gt;&lt;BR /&gt;My blt dataset has many rows of data in it.&lt;BR /&gt;&lt;BR /&gt;This dataset also has just one month of data in it so ultimately I am trying to see when sales are made on each day broken down per hour, hence the first bit of code to extract the hour from the SAS datetime variable.</description>
      <pubDate>Fri, 29 Apr 2022 11:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810581#M319643</guid>
      <dc:creator>programeerSAS</dc:creator>
      <dc:date>2022-04-29T11:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Hour Function from datetime not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810585#M319645</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299508"&gt;@programeerSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Kurt&lt;BR /&gt;&lt;BR /&gt;My blt dataset has many rows of data in it.&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your log says something completely different. I believe SAS in this.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 11:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810585#M319645</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-29T11:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Hour Function from datetime not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810592#M319649</link>
      <description>&lt;P&gt;Can you provide few rows of your data?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 11:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810592#M319649</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-04-29T11:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Hour Function from datetime not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810595#M319652</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299508"&gt;@programeerSAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide the &lt;FONT color="#FF0000"&gt;ENTIRE&lt;/FONT&gt; log for this DATA step, instead of what you did was just show us pieces of the log. Please copy the log as text and then click on the &amp;lt;/&amp;gt; and paste the log into the window that appears.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Insert Log Icon in SAS Communities.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66171iFEC370B1DBF07B28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Insert Log Icon in SAS Communities.png" alt="Insert Log Icon in SAS Communities.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 12:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810595#M319652</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-29T12:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Hour Function from datetime not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810778#M319751</link>
      <description>&lt;P&gt;Hi Kurt - you were spot on!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had the table open but a piece of my code messed up the dataset. I re-imported, ran the code as is and voila!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 30 Apr 2022 07:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hour-Function-from-datetime-not-working/m-p/810778#M319751</guid>
      <dc:creator>programeerSAS</dc:creator>
      <dc:date>2022-04-30T07:31:11Z</dc:date>
    </item>
  </channel>
</rss>

