<?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: Change numeric variable of type xx.xx to a time variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550546#M152868</link>
    <description>&lt;P&gt;When specifying numeric formats, keep this in mind:&lt;/P&gt;
&lt;P&gt;The first number specifies the&amp;nbsp;&lt;EM&gt;whole&lt;/EM&gt; length, including digits before the comma, digits after the comma, the comma itself, and any other characters that the format will produce. The second number specifies only the fractional digits. So 3.3 can never work, as the overall length doesn't even leave space for the comma.&lt;/P&gt;
&lt;P&gt;See where this code (which works) differs from yours:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data schedules;
input event_time;
cards;
15.30
12.45
;
run;

proc sql;
create table events as
select input(translate(put(event_time,z5.2),':','.'),time5.) format time5. as event_time_converted
from schedules;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The Zw.d format forces leading blanks. A length of 5 is needed for 2 digits + comma + 2 digits.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Apr 2019 08:43:53 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-04-12T08:43:53Z</dc:date>
    <item>
      <title>Change numeric variable of type xx.xx to a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550533#M152862</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to convert in a SQL procedure a numeric variable (which represents the time of an event as "15.30" for 15:30 or 12.45 such as 12:45) to a time one (like 15:30 or 12:45). But I'm not able to get the minutes, I can just get 15:00 when the numeric variable is 15.30 for example. Would you know how to fix it please ? Thank you in advance for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The related query is as following :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table events as
select input(put(event_time,3.3),hhmmss4.) format time5. as event_time_converted
from schedules;
quit&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 08:03:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550533#M152862</guid>
      <dc:creator>Olscream</dc:creator>
      <dc:date>2019-04-12T08:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Change numeric variable of type xx.xx to a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550535#M152863</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table events as
select input(translate(event_time,':',"."),hhmmss4.) format time5. as event_time_converted
from schedules;
quit&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Apr 2019 08:11:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550535#M152863</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-04-12T08:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Change numeric variable of type xx.xx to a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550536#M152864</link>
      <description>&lt;P&gt;Please try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(cat(event_time), time.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you aren't forced to use proc sql for such task, switching to data step is recommended for easier debugging.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry, should have looked closer at the result. Cat-function does not help here, we need put:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(put(event_time, 5.2), time.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Apr 2019 08:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550536#M152864</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-04-12T08:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Change numeric variable of type xx.xx to a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550539#M152865</link>
      <description>&lt;P&gt;Thanks ! But it doesn't perfectly work :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: Function TRANSLATE requires a character expression as argument 1.
ERROR: Numeric format F in PUT function requires a numeric argument.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Apr 2019 08:20:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550539#M152865</guid>
      <dc:creator>Olscream</dc:creator>
      <dc:date>2019-04-12T08:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Change numeric variable of type xx.xx to a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550546#M152868</link>
      <description>&lt;P&gt;When specifying numeric formats, keep this in mind:&lt;/P&gt;
&lt;P&gt;The first number specifies the&amp;nbsp;&lt;EM&gt;whole&lt;/EM&gt; length, including digits before the comma, digits after the comma, the comma itself, and any other characters that the format will produce. The second number specifies only the fractional digits. So 3.3 can never work, as the overall length doesn't even leave space for the comma.&lt;/P&gt;
&lt;P&gt;See where this code (which works) differs from yours:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data schedules;
input event_time;
cards;
15.30
12.45
;
run;

proc sql;
create table events as
select input(translate(put(event_time,z5.2),':','.'),time5.) format time5. as event_time_converted
from schedules;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The Zw.d format forces leading blanks. A length of 5 is needed for 2 digits + comma + 2 digits.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 08:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-numeric-variable-of-type-xx-xx-to-a-time-variable/m-p/550546#M152868</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-12T08:43:53Z</dc:date>
    </item>
  </channel>
</rss>

