<?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 converting time to string in one step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718336#M222301</link>
    <description>&lt;P&gt;I have a &lt;STRONG&gt;time variable&lt;/STRONG&gt; that looks like this 08:00 and I want it to turn into a &lt;STRONG&gt;string variable&lt;/STRONG&gt; that looks the same way.&lt;/P&gt;&lt;P&gt;How would you go about coding this?&lt;/P&gt;</description>
    <pubDate>Wed, 10 Feb 2021 17:59:48 GMT</pubDate>
    <dc:creator>K_S</dc:creator>
    <dc:date>2021-02-10T17:59:48Z</dc:date>
    <item>
      <title>converting time to string in one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718336#M222301</link>
      <description>&lt;P&gt;I have a &lt;STRONG&gt;time variable&lt;/STRONG&gt; that looks like this 08:00 and I want it to turn into a &lt;STRONG&gt;string variable&lt;/STRONG&gt; that looks the same way.&lt;/P&gt;&lt;P&gt;How would you go about coding this?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 17:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718336#M222301</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2021-02-10T17:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: converting time to string in one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718339#M222304</link>
      <description>&lt;P&gt;Use the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0mlfb88dkhbmun1x08qbh5xbs7e.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;PUT&lt;/A&gt; or &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p12zqzvwx4dv6kn1p9crijxswolk.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;PUTN&lt;/A&gt; function with the same&amp;nbsp;format that is specified for the numeric time variable.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 18:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718339#M222304</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-10T18:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: converting time to string in one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718650#M222432</link>
      <description>&lt;P&gt;Thanks. The time variable I have is not numeric. It is a time variable and the numeric formats don't work on it. Any other tips?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 16:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718650#M222432</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2021-02-11T16:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: converting time to string in one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718651#M222433</link>
      <description>&lt;P&gt;If it is not numeric, then it is already a string (character), so there's no need for converting.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 16:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718651#M222433</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-11T16:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: converting time to string in one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718656#M222436</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127053"&gt;@K_S&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks. The time variable I have is not numeric. It is a time variable and the numeric formats don't work on it. Any other tips?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS only has two data types. Floating point numbers and fixed length character strings. If the variable actually has time values then it contains the number of seconds since midnight.&amp;nbsp; It would only look like '08:00' if you were displaying the value with the TIME5. format.&lt;/P&gt;
&lt;PRE&gt;1335  data _null_;
1336    now=time();
1337    put now= time5. now= comma12. ;
1338  run;

now=11:27 now=41,265
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;So to convert it to the formatted value use the PUT() or PUTN() function.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input time time. ;
  string1=put(time,time5.);
  string2=putn(time,'time5.');
  format time time5.;
  string3=vvalue(time);
  string4=vvaluex('time');
  put (_all_) (=/);
cards;
08:00
11:27
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;1363  data test;
1364    input time time. ;
1365    string1=put(time,time5.);
1366    string2=putn(time,'time5.');
1367    format time time5.;
1368    string3=vvalue(time);
1369    string4=vvaluex('time');
1370    put (_all_) (=/);
1371  cards;


time=8:00
string1=8:00
string2=8:00
string3=8:00
string4=8:00

time=11:27
string1=11:27
string2=11:27
string3=11:27
string4=11:27
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 16:33:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-time-to-string-in-one-step/m-p/718656#M222436</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-11T16:33:42Z</dc:date>
    </item>
  </channel>
</rss>

