<?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: How to convert second to time format in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102577#M28728</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need a character variable showing 01:01:02 Mike has provided the solution.&amp;nbsp; But you would need to keep the SECOND variable if you plan to do any time interval calculations or anlysis that goes beyond frequencies.&amp;nbsp; So you might simply apply the time8.0 format to SECOND for reporting purposes and avoid creating the new TIME variable entriely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you could do things like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; tables second;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format second time8.0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which would give you tables in whole second intervals, but reported in the hh:mm:ss format that you requested.&amp;nbsp; Or if you used time5.0 you'd get whole minute intervals (hh:mm).&amp;nbsp; Or time2.0 for hours.&amp;nbsp; But remember the TIME format is for a duration measure (not time-of-day), so it will display values of 24 hours and beyond.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if you want to see 25:01:01 reported as 01:01:01, then you can use the TOD8.0, TOD5.0, or TOD3.0 formats.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Aug 2012 18:12:37 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2012-08-23T18:12:37Z</dc:date>
    <item>
      <title>How to convert second to time format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102574#M28725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a time variable denotes 3662 seconds(3600+60+2),&lt;/P&gt;&lt;P&gt;I wonder how to convert the 3662 seconds to 1hour and 1minutes and 2 second (01:01:02) format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;second=3662;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data need;/*this need modification*/&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;time= input(second,hh:mm:ss.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2012 17:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102574#M28725</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-08-23T17:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert second to time format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102575#M28726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FYI,&lt;/P&gt;&lt;P&gt;data need;/*this need modification*/&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;time=put(second,time13.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2012 17:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102575#M28726</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-08-23T17:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert second to time format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102576#M28727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use hms function :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;data have;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;second=3662;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;data need;/*this need modification*/&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;set have;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;format time time10.;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;time= hms(0,0,second);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;proc print; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2012 17:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102576#M28727</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-08-23T17:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert second to time format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102577#M28728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need a character variable showing 01:01:02 Mike has provided the solution.&amp;nbsp; But you would need to keep the SECOND variable if you plan to do any time interval calculations or anlysis that goes beyond frequencies.&amp;nbsp; So you might simply apply the time8.0 format to SECOND for reporting purposes and avoid creating the new TIME variable entriely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you could do things like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; tables second;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format second time8.0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which would give you tables in whole second intervals, but reported in the hh:mm:ss format that you requested.&amp;nbsp; Or if you used time5.0 you'd get whole minute intervals (hh:mm).&amp;nbsp; Or time2.0 for hours.&amp;nbsp; But remember the TIME format is for a duration measure (not time-of-day), so it will display values of 24 hours and beyond.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if you want to see 25:01:01 reported as 01:01:01, then you can use the TOD8.0, TOD5.0, or TOD3.0 formats.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2012 18:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102577#M28728</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-23T18:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert second to time format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102578#M28729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you have skipped that HMS function?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2012 18:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102578#M28729</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-08-23T18:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert second to time format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102579#M28730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, since SAS stores time values in units of seconds. But I prefer to remain independent of internal representations, even when they are documented. That's why I prefer to use INTNX("DAY', aDate, 1) instead of aDate+1 to find the day after aDate. Call me a purist!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2012 19:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102579#M28730</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-08-23T19:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert second to time format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102580#M28731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mike's method return character and PG's method keep numeric,&lt;/P&gt;&lt;P&gt;if we use call symput('ggg',time); in a datastep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the character one will get atime formated&amp;nbsp; &amp;amp;ggg,while the numeric one will keep the original numeric value to the macro varialbe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2012 20:11:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102580#M28731</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-08-23T20:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert second to time format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102581#M28732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want a macro var to get a formatted value then use the PUT function as the second argument of call symput:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput('ggg',put(time,time8.0))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a general rule, I avoid creating character vars based on numeric vars already in the data set, at least when those character values can be created by applying a format to the numeric value, and especially when the format is a standard SAS-supplied format.&amp;nbsp; It saves space and protects against a change in the numeric var not being propagated to the related character var.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 13:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-second-to-time-format/m-p/102581#M28732</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-24T13:02:05Z</dc:date>
    </item>
  </channel>
</rss>

