<?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: Convert Character Expression to Time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-Expression-to-Time/m-p/444926#M283038</link>
    <description>&lt;P&gt;Or simpler:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    sastime = timepart( intnx('dthour',input(time,time5.),-1,'same'));
    format sastime time5.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 12 Mar 2018 20:10:09 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-03-12T20:10:09Z</dc:date>
    <item>
      <title>Convert Character Expression to Time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-Expression-to-Time/m-p/444867#M283036</link>
      <description>&lt;P&gt;I have a column with hours and minutes.&amp;nbsp;Some examples&amp;nbsp;below:&lt;/P&gt;&lt;P&gt;00:00&lt;/P&gt;&lt;P&gt;00:15&lt;/P&gt;&lt;P&gt;11:45&lt;/P&gt;&lt;P&gt;12:30&lt;/P&gt;&lt;P&gt;23:30&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The format and informat of the column is $5. I need to subtract 1 hour from this column. So the result would be:&lt;/P&gt;&lt;P&gt;23:00&lt;/P&gt;&lt;P&gt;23:15&lt;/P&gt;&lt;P&gt;10:45&lt;/P&gt;&lt;P&gt;11:30&lt;/P&gt;&lt;P&gt;22:30&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the easiest way of doing this? Should I be converting to time and then subtract or is there another way? Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 18:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Character-Expression-to-Time/m-p/444867#M283036</guid>
      <dc:creator>ummath16</dc:creator>
      <dc:date>2018-03-12T18:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character Expression to Time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-Expression-to-Time/m-p/444912#M283037</link>
      <description>&lt;P&gt;If your variable is character then you need to make a new variable with the numeric time (or write a whole bunch of code that the SAS time functions will handle for you with a time value). However since you are involved with crossing midnight boundaries you need to considire a date portion,You do not indicate whether the result should be numeric(a SAS time value) or character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
    set have;
    sastime = timepart( intnx('hour',dhms('01JAN2018'd,0,0,input(time,time5.)),-1,'same'));
    format sastime time5.;
run;&lt;/PRE&gt;
&lt;P&gt;The INPUT portion creates the time of day of your time variable, the DHMS creates a datetime value based on the shown date, INTNX function increments the resulting datetime variable by minus 1 hour and keeps the minutes (and seconds) the same, then TIMEPART extracts the time portion only of the resulting date time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The format displayes the SASTIME value results as 00:45.&lt;/P&gt;
&lt;P&gt;Without the date portion the -1 hour would yield negative times like 00:00 - 01:00 = -01:00 instead of 23:00&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 19:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Character-Expression-to-Time/m-p/444912#M283037</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-12T19:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character Expression to Time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-Expression-to-Time/m-p/444926#M283038</link>
      <description>&lt;P&gt;Or simpler:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    sastime = timepart( intnx('dthour',input(time,time5.),-1,'same'));
    format sastime time5.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Mar 2018 20:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Character-Expression-to-Time/m-p/444926#M283038</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-12T20:10:09Z</dc:date>
    </item>
  </channel>
</rss>

