<?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: timevalue into numaric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/timevalue-into-numaric/m-p/780698#M248778</link>
    <description>&lt;P&gt;I would use the TIME. format instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  timevalue=time();
  format timevalue time11.2;
  put timevalue=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The time-value will then display nicely. And you can subtract it from another time-value to get the number of seconds between the two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you MUST do it the other way, it would be better to do it like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;                                            
  timevalue=time();                                     
  timevalue=hour(timevalue)*10000+minute(timevalue)*100 
            +second(timevalue);                         
  format timevalue z9.2;                                
  put timevalue=;                                       
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 17 Nov 2021 10:55:11 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2021-11-17T10:55:11Z</dc:date>
    <item>
      <title>timevalue into numaric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/timevalue-into-numaric/m-p/780692#M248772</link>
      <description>&lt;P&gt;All,&lt;/P&gt;
&lt;P&gt;If I run below code it works majority of time.&lt;/P&gt;
&lt;P&gt;But won't work few times&lt;/P&gt;
&lt;P&gt;For example, if the&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1. TIME = 15:01:50&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;TIMEVALUE =151.5&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;But looking for 1501.50&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;2.&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;TIME = 00:00:09&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;TIMEVALUE = 0.9&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Looking for 0000.09&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;3. TIME = 09:22:09&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;TIMEVALUE = 922.9&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Looking for 0922.09&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.time_test;
    format time time8.;
/*    time = "14:04:46"t;*/
      time=time();
      timevalue = input(strip(hour(time))||strip(minute(time))||strip(.)||strip(round(second(time))),8.2);
  
    put time ;
    put timevalue;
      run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Nov 2021 09:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/timevalue-into-numaric/m-p/780692#M248772</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2021-11-17T09:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: timevalue into numaric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/timevalue-into-numaric/m-p/780695#M248775</link>
      <description>&lt;P&gt;Use the NLTIME function (there is also a NLDATE function). See example program below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NLTIME returns a char value, this is converted to a numeric and the Z7.2 will print leading zeros&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  do timevalue = "15:01:50"t, "00:00:09"t , "09:22:09"t;
    newTimeValue = nltime(timeValue, '%H%M.%S');
    newTimeValue_n = input(newTimeValue, best8.);
    output;
  end;

  format timevalue tod8. newTimeValue_n z7.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 10:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/timevalue-into-numaric/m-p/780695#M248775</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2021-11-17T10:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: timevalue into numaric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/timevalue-into-numaric/m-p/780698#M248778</link>
      <description>&lt;P&gt;I would use the TIME. format instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  timevalue=time();
  format timevalue time11.2;
  put timevalue=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The time-value will then display nicely. And you can subtract it from another time-value to get the number of seconds between the two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you MUST do it the other way, it would be better to do it like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;                                            
  timevalue=time();                                     
  timevalue=hour(timevalue)*10000+minute(timevalue)*100 
            +second(timevalue);                         
  format timevalue z9.2;                                
  put timevalue=;                                       
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Nov 2021 10:55:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/timevalue-into-numaric/m-p/780698#M248778</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2021-11-17T10:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: timevalue into numaric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/timevalue-into-numaric/m-p/780701#M248780</link>
      <description>&lt;P&gt;Why do you want such a useless number?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 11:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/timevalue-into-numaric/m-p/780701#M248780</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-17T11:13:12Z</dc:date>
    </item>
  </channel>
</rss>

