<?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 time to character in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146131#M38806</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;if for some reason the variable is in a character format you can allways create a new variable and converet it&amp;nbsp; to a numeric format using&lt;STRONG&gt; input&lt;/STRONG&gt; .&lt;/P&gt;&lt;P&gt;for example :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data report;&lt;/P&gt;&lt;P&gt;set report;&lt;/P&gt;&lt;P&gt;hour=hour(time);&lt;/P&gt;&lt;P&gt;hour1=input(hour,12.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;good luck&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Nov 2013 08:38:28 GMT</pubDate>
    <dc:creator>anonymous_user</dc:creator>
    <dc:date>2013-11-18T08:38:28Z</dc:date>
    <item>
      <title>Converting time to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146127#M38802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Im having and issue with a time column.&lt;/P&gt;&lt;P&gt;the column is a time9. 14:04:00&lt;/P&gt;&lt;P&gt;WHat&amp;nbsp; i need to pull is the hour segment 14&lt;/P&gt;&lt;P&gt;when I did is a data step &lt;/P&gt;&lt;P&gt;data report;&lt;/P&gt;&lt;P&gt;set report;&lt;/P&gt;&lt;P&gt;hour= substr( left( time) ,2,4);&lt;/P&gt;&lt;P&gt;it gives the sas date of 50640. This is what it pulls in 0640&amp;nbsp; But the col I'm refer looks like this 14:04:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your assistance &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2013 22:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146127#M38802</guid>
      <dc:creator>BETO</dc:creator>
      <dc:date>2013-11-15T22:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146128#M38803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your time variable is a true SAS time value, you should use hour = hour(time) to get the hour number or hour=put(hour(time),best.) to get the character representation.&lt;/P&gt;&lt;P&gt;If time is a character representation of time then you should use hour = scan(time,1,":") . - PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2013 22:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146128#M38803</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-11-15T22:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146129#M38804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI PGStats,&lt;/P&gt;&lt;P&gt;the hour did work it gave&amp;nbsp; me the hour. But it converted it to a character for example &lt;/P&gt;&lt;P&gt;14:04:00 it gave me a 14&amp;nbsp; as a character what can i do within the datastep to make it a number? THANKS &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data report;&lt;/P&gt;&lt;P&gt;set report;&lt;/P&gt;&lt;P&gt;hour=hour(time):&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2013 00:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146129#M38804</guid>
      <dc:creator>BETO</dc:creator>
      <dc:date>2013-11-16T00:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146130#M38805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It must be that variable &lt;STRONG&gt;hour&lt;/STRONG&gt; is already declared as a character variable prior to the &lt;STRONG&gt;hour=hour(time)&lt;/STRONG&gt; statement. Look at SAS log, there must be a statement such as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;NOTE: Numeric values have been converted to character&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; values at the places given by: (Line):(Column).&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the following test:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data report;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;length hourText $8;&amp;nbsp;&amp;nbsp; /* Declare hourText as a character variable */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;time = '14:30:00't;&amp;nbsp;&amp;nbsp; /* time is a true SAS time value */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;hourText = hour(time);&amp;nbsp; /* Implies a conversion to character */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;hourNumber = hour(time);&amp;nbsp; /* Number result is assigned to a numeric variable (by default) */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to get a number, assign the result of &lt;STRONG&gt;hour(time)&lt;/STRONG&gt; to a variable that hasn't been declared as a character variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2013 03:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146130#M38805</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-11-16T03:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146131#M38806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;if for some reason the variable is in a character format you can allways create a new variable and converet it&amp;nbsp; to a numeric format using&lt;STRONG&gt; input&lt;/STRONG&gt; .&lt;/P&gt;&lt;P&gt;for example :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data report;&lt;/P&gt;&lt;P&gt;set report;&lt;/P&gt;&lt;P&gt;hour=hour(time);&lt;/P&gt;&lt;P&gt;hour1=input(hour,12.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;good luck&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2013 08:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-time-to-character/m-p/146131#M38806</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2013-11-18T08:38:28Z</dc:date>
    </item>
  </channel>
</rss>

