<?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 the numeric variable in time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414955#M101714</link>
    <description>&lt;P&gt;It's not working&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: navy; background: white;"&gt;&lt;FONT size="3"&gt;data&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt; Data_Base5;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;&lt;FONT size="3"&gt;set&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt; Data_Base4;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;&lt;FONT size="3"&gt;input&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt; Time_Def @@;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;&lt;FONT size="3"&gt;format&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt; Time &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;&lt;FONT size="3"&gt;Time8.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;Time_def=hms(floor(Time/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;&lt;FONT size="3"&gt;100&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;), mod(Time,&lt;/FONT&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;&lt;FONT size="3"&gt;100&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;), &lt;/FONT&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;&lt;FONT size="3"&gt;0&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;);&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: navy; background: white;"&gt;&lt;FONT size="3"&gt;Proc&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: navy; background: white;"&gt;&lt;FONT size="3"&gt;print&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: navy; background: white;"&gt;&lt;FONT size="3"&gt;RUN&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;ERROR: No. DATALINES or INFILE statement&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2017 21:01:27 GMT</pubDate>
    <dc:creator>Diana_Alfaro</dc:creator>
    <dc:date>2017-11-20T21:01:27Z</dc:date>
    <item>
      <title>convert the numeric variable in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414938#M101706</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the numeric variable time with e.g. the values 819.00, 1445.00, 2159.00, ... . Those values should be converted to a SAS time format representing the clock time hh:mm:ss am/pm e.g. 8:19:00 am, 14:45:00 am, 21:59:00 pm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you help me to figure out the code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 20:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414938#M101706</guid>
      <dc:creator>Diana_Alfaro</dc:creator>
      <dc:date>2017-11-20T20:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: convert the numeric variable in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414941#M101707</link>
      <description>&lt;P&gt;HMS function and basic math:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input timeN @@;
time = hms(floor(timeN/100), mod(timeN,100), 0);
format time time8.;
datalines;
819.00 1445.00 2159.00
;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2017 20:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414941#M101707</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-11-20T20:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: convert the numeric variable in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414949#M101711</link>
      <description>&lt;P&gt;Use PUT to convert it to a text field&lt;/P&gt;
&lt;P&gt;Use INPUT to read it correctly as a time field using the informat, hhmmss.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;data from_text;
informat time_old hhmmss.;
format time_old time.;
input time_old;
cards;
819
1445
2159
;
run;


data have_diff;
input num;
cards;
819
1445
2159
;
run;


data want;
set have_diff;
x = input(put(num, 8.), hhmmss.);
format x time.;
run;

title 'results from reading in as text file';
proc print data=from_text;
title 'results from using input, where data already exists';
proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&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/178731"&gt;@Diana_Alfaro&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the numeric variable time with e.g. the values 819.00, 1445.00, 2159.00, ... . Those values should be converted to a SAS time format representing the clock time hh:mm:ss am/pm e.g. 8:19:00 am, 14:45:00 am, 21:59:00 pm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you help me to figure out the code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Diana&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 20:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414949#M101711</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-20T20:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: convert the numeric variable in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414955#M101714</link>
      <description>&lt;P&gt;It's not working&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: navy; background: white;"&gt;&lt;FONT size="3"&gt;data&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt; Data_Base5;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;&lt;FONT size="3"&gt;set&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt; Data_Base4;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;&lt;FONT size="3"&gt;input&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt; Time_Def @@;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;&lt;FONT size="3"&gt;format&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt; Time &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;&lt;FONT size="3"&gt;Time8.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;Time_def=hms(floor(Time/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;&lt;FONT size="3"&gt;100&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;), mod(Time,&lt;/FONT&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;&lt;FONT size="3"&gt;100&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;), &lt;/FONT&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;&lt;FONT size="3"&gt;0&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;);&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: navy; background: white;"&gt;&lt;FONT size="3"&gt;Proc&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: navy; background: white;"&gt;&lt;FONT size="3"&gt;print&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: navy; background: white;"&gt;&lt;FONT size="3"&gt;RUN&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;FONT size="3"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;ERROR: No. DATALINES or INFILE statement&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 21:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414955#M101714</guid>
      <dc:creator>Diana_Alfaro</dc:creator>
      <dc:date>2017-11-20T21:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: convert the numeric variable in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414961#M101717</link>
      <description>it's not working&lt;BR /&gt;Error&lt;BR /&gt;1. Informat $HHMMSS was not found or could not be loaded.&lt;BR /&gt;2. Format $TIME was not found or could not be loaded.</description>
      <pubDate>Mon, 20 Nov 2017 21:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414961#M101717</guid>
      <dc:creator>Diana_Alfaro</dc:creator>
      <dc:date>2017-11-20T21:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: convert the numeric variable in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414965#M101720</link>
      <description>&lt;P&gt;1. Please confirm that your variable is numeric. Are you tring to implement this on data you already have in SAS or during an import step?&lt;/P&gt;
&lt;P&gt;2. Saying something works isn't helpful. Please show your full code and log. Mine solution includes a fully worked example that first imports a set of sample data and then converts it. I would compare it against your data/code and see how it differs, that will tell you where your mistake is.&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/178731"&gt;@Diana_Alfaro&lt;/a&gt; wrote:&lt;BR /&gt;it's not working&lt;BR /&gt;Error&lt;BR /&gt;1. Informat $HHMMSS was not found or could not be loaded.&lt;BR /&gt;2. Format $TIME was not found or could not be loaded.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 21:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414965#M101720</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-20T21:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: convert the numeric variable in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414972#M101722</link>
      <description>&lt;P&gt;Fool proof:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Data_Base5;
set Data_Base4;
format Time_def Time8.;
Time_def = hms(floor(input(cats(Time),best.)/100), mod(input(cats(Time),best.),100), 0);
run;

Proc print;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2017 21:54:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/414972#M101722</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-11-20T21:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: convert the numeric variable in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/415083#M101763</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/178731"&gt;@Diana_Alfaro&lt;/a&gt; wrote:&lt;BR /&gt;it's not working&lt;BR /&gt;Error&lt;BR /&gt;1. Informat $HHMMSS was not found or could not be loaded.&lt;BR /&gt;2. Format $TIME was not found or could not be loaded.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which means that your time variable is NOT numeric, but character. It just looks like a number. Verify that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is one of the reasons why we ask people to post their example datasets in a data step, so we can recreate their data &lt;EM&gt;as is&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the macro provided in &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; to convert your dataset to a data step, and post that here according to the advice in &lt;A href="https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce" target="_blank"&gt;https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 08:52:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-the-numeric-variable-in-time/m-p/415083#M101763</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-21T08:52:26Z</dc:date>
    </item>
  </channel>
</rss>

