<?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: Converting a numeric  value into a character time value, non standard in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931157#M83508</link>
    <description>&lt;P&gt;13.48 becomes 13:48. Is that 13 hours and 48 minutes, or 13 minutes and 48 seconds? How can you reconcile a decimal of 13.48, which is less than 13 1/2 becoming something larger that 13 1/2 (13 min and 48 seconds is larger than 13 1/2 minutes) ????&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Explain in more detail what the data is, and what you want to do with it.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jun 2024 15:22:33 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-06-06T15:22:33Z</dc:date>
    <item>
      <title>Converting a numeric  value into a character time value, non standard</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931148#M83505</link>
      <description>&lt;DIV&gt;Hi,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I need to convert a time variable currently in character toa numeric but the data is non standard format;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data have ;&lt;/DIV&gt;
&lt;DIV&gt;input starttm 8.;&lt;/DIV&gt;
&lt;DIV&gt;datalines;&lt;/DIV&gt;
&lt;DIV&gt;13.48&lt;/DIV&gt;
&lt;DIV&gt;9&lt;/DIV&gt;
&lt;DIV&gt;10&lt;/DIV&gt;
&lt;DIV&gt;9.3&lt;/DIV&gt;
&lt;DIV&gt;8.56&lt;/DIV&gt;
&lt;DIV&gt;11.10&lt;/DIV&gt;
&lt;DIV&gt;.&lt;/DIV&gt;
&lt;DIV&gt;1.2&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;/*&lt;/DIV&gt;
&lt;DIV&gt;Want the data to look:&lt;/DIV&gt;
&lt;DIV&gt;13:48&lt;/DIV&gt;
&lt;DIV&gt;09:00&lt;/DIV&gt;
&lt;DIV&gt;10:00&lt;/DIV&gt;
&lt;DIV&gt;09:30&lt;/DIV&gt;
&lt;DIV&gt;08:56&lt;/DIV&gt;
&lt;DIV&gt;11:10&lt;/DIV&gt;
&lt;DIV&gt;.&lt;/DIV&gt;
&lt;DIV&gt;01:20&lt;/DIV&gt;
&lt;DIV&gt;*/&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data want;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; length srtm1 srtm3 srtm4_ srtm4 $5;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; set have;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; srtm1=put(starttm,time5.);/* Not working. All observatsion=0:00*/&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; *srtm2=put(starttm,hhmmss5.);* Works only for observations 2,3*/;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; srtm3=put(starttm,tod5.);/* Not working. All observatsion=0:00*/&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; srtm4_=tranwrd(strip(put(starttm,best5.)),".",":");/* Not working. same as original*/&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; if starttm ^=. then do;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;if index(srtm4_,":")=3 then srtm4= srtm4_;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; else if index(srtm4_,":")=2&amp;nbsp; then srtm4= srtm4_||"0";&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; else if index(srtm4_,":")=20 then srtm4= srtm4_||":00";&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; end;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; if index(srtm4_,":")&amp;gt;0 then srtm5= input(srtm4_,time5.); /* Not working dor observation 4,6*/&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; else&amp;nbsp; &amp;nbsp;srtm5= input(srtm4_,hhmmss5.);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; format srtm5 time5.;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Any suggestions as to how to get a format that works for each value?&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Thanks.&lt;/DIV&gt;</description>
      <pubDate>Thu, 06 Jun 2024 15:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931148#M83505</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2024-06-06T15:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a numeric  value into a character time value, non standard</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931156#M83507</link>
      <description>&lt;P&gt;Two questions to start. You say you have character values but your data step creates the variable starttm as numeric. So is YOUR variable character of numeric?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, do you want an actual time value or just something character that fakes it? (Strongly recommend actual time values as they can be worked with much easier).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The below custom Format will display the example &lt;STRONG&gt;numeric &lt;/STRONG&gt;values in the desired appearance:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
picture colsep 
  low-high='99:99' (decsep=':')
  . = '.'
;
run;

proc print data=have noobs;
  format starttm colsep5.;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jun 2024 15:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931156#M83507</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-06T15:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a numeric  value into a character time value, non standard</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931157#M83508</link>
      <description>&lt;P&gt;13.48 becomes 13:48. Is that 13 hours and 48 minutes, or 13 minutes and 48 seconds? How can you reconcile a decimal of 13.48, which is less than 13 1/2 becoming something larger that 13 1/2 (13 min and 48 seconds is larger than 13 1/2 minutes) ????&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Explain in more detail what the data is, and what you want to do with it.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 15:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931157#M83508</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-06T15:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a numeric  value into a character time value, non standard</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931169#M83510</link>
      <description>&lt;P&gt;I received the data as is. I was told that 9.30 represent 09:30 9 hours and 30 min&lt;/P&gt;
&lt;P&gt;I have to create a date time variable that has the date and the time .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 18:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931169#M83510</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2024-06-06T18:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a numeric  value into a character time value, non standard</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931170#M83511</link>
      <description>&lt;P&gt;I received the data with the time in a numeric decimal format.&amp;nbsp; I was told that 9.30 represents 9 hours and 30 minutes.&lt;/P&gt;
&lt;P&gt;I need to append this to a date variable to get a character variable with the date and time together as a character.&lt;/P&gt;
&lt;P&gt;If I want to use the DHMS function I need the time in a standard numeric format, So I thought of converting the time variable to a character, standardizing it, reconverting it to a numeric variable and use it with DHMS.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 18:08:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931170#M83511</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2024-06-06T18:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a numeric  value into a character time value, non standard</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931172#M83512</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3443"&gt;@Kc2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I received the data as is. I was told that 9.30 represent 09:30 9 hours and 30 min&lt;/P&gt;
&lt;P&gt;I have to create a date time variable that has the date and the time .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But this doesn't answer my other question: is 13.48 really 13 hours and 48 minutes, or does the .48 indicate 0.48 hours which is not 48 minutes?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 18:54:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931172#M83512</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-06T18:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a numeric  value into a character time value, non standard</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931175#M83513</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3443"&gt;@Kc2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I received the data as is. I was told that 9.30 represent 09:30 9 hours and 30 min&lt;/P&gt;
&lt;P&gt;I have to create a date time variable that has the date and the time .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This will create the time part of :&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
picture colsep 
  low-high='99:99' (decsep=':')
  . = '.'
;
run;

data want;
  set have;
  timeval = input(put(starttm,colsep5.),time.);
  format timeval time5.;
run;&lt;/PRE&gt;
&lt;P&gt;if you have a date valued SAS variable then to get a datetime you would use:&lt;/P&gt;
&lt;PRE&gt;datetimevar = dhms(datevariable,0,0,timeval);&lt;/PRE&gt;
&lt;P&gt;The DHMS , D=date H=hour M=minute s=second, function is to make datetime values from date, hour, minute and seconds. With a time value you set the H and M to zero and the Timeval has enough seconds for the hour, minute and seconds if there had been any.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 19:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931175#M83513</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-06T19:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a numeric  value into a character time value, non standard</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931184#M83514</link>
      <description>&lt;P&gt;thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;, You are the best!.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 19:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-a-numeric-value-into-a-character-time-value-non/m-p/931184#M83514</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2024-06-06T19:50:03Z</dc:date>
    </item>
  </channel>
</rss>

