<?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: Convert numeric variable into SAS time variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464577#M118460</link>
    <description>&lt;P&gt;Why do you call a time value "date"? That will set you down the wrong path to begin with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   time = input(put(date,z4.),hhmmss4.);
   format time time5.;
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 23 May 2018 20:59:14 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-05-23T20:59:14Z</dc:date>
    <item>
      <title>Convert numeric variable into SAS time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464485#M118428</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;I have tried many times&amp;nbsp; to convert date&amp;nbsp; into sas time value but do not get the result. I am sharing my syntax&amp;nbsp; please&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;correct me where I am wrong. All the syntax executed perfectly except last one i.e final although it has converted from character to numeric type but its showing blank row.&lt;/DIV&gt;&lt;DIV&gt;data test;&lt;/DIV&gt;&lt;DIV&gt;infile datalines;&lt;/DIV&gt;&lt;DIV&gt;input id$ date;&lt;/DIV&gt;&lt;DIV&gt;datalines;&lt;/DIV&gt;&lt;DIV&gt;1001&amp;nbsp; &amp;nbsp;505&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;1002&amp;nbsp; &amp;nbsp;1023&lt;/DIV&gt;&lt;DIV&gt;;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;here dates are given into numeric type I want to convert into 05:05 and 10:23 hour and minute format.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data test1;&lt;/DIV&gt;&lt;DIV&gt;set test;&lt;/DIV&gt;&lt;DIV&gt;char = put(date, z4.);&lt;/DIV&gt;&lt;DIV&gt;hour = substr(char,1,2);&lt;/DIV&gt;&lt;DIV&gt;min = substr(char,3,2);&lt;/DIV&gt;&lt;DIV&gt;con = trim(hour)||':'||trim(min);&lt;/DIV&gt;&lt;DIV&gt;final = input(con,best12.);&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;</description>
      <pubDate>Wed, 23 May 2018 17:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464485#M118428</guid>
      <dc:creator>ashkum</dc:creator>
      <dc:date>2018-05-23T17:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric variable into SAS time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464490#M118432</link>
      <description>&lt;P&gt;In your INPUT you need to give TIME5. informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
format final time5.;
set test;
char = put(date, z4.);
hour = substr(char,1,2);
min = substr(char,3,2);
con = trim(hour)||':'||trim(min);
final = input(con,time5.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 May 2018 17:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464490#M118432</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-05-23T17:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric variable into SAS time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464495#M118436</link>
      <description>&lt;P&gt;thanks a ton....SuryaKiran&lt;/P&gt;&lt;P&gt;Do you have any other syntax to solve this problem...&lt;/P&gt;&lt;P&gt;this method looks lengthy&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 18:06:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464495#M118436</guid>
      <dc:creator>ashkum</dc:creator>
      <dc:date>2018-05-23T18:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric variable into SAS time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464500#M118439</link>
      <description>&lt;P&gt;You can avoid creating unnecessary new variables and can create only one by combining all the function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
format time time5.;
set test;
Time=input(CATX(":",substr(put(date, z4.),1,2),substr(put(date, z4.),3,2)),TIME5.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't think this is a lengthy process. If your data is not formatted properly then you need to go for all these extra.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 18:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464500#M118439</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-05-23T18:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric variable into SAS time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464511#M118441</link>
      <description>&lt;P&gt;Why not keep FINAL as a sas numeric time value (i.e. the number of seconds after midnight)?&amp;nbsp; You can apply a format to display it as desired.&amp;nbsp; And because it's a sas time-value you can do all sorts of time-interval calculations, if needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
  set test;
  final=  3600*floor(date/100)+ 60*mod(date,100);
  format final time5.0;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 May 2018 18:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464511#M118441</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-23T18:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric variable into SAS time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464577#M118460</link>
      <description>&lt;P&gt;Why do you call a time value "date"? That will set you down the wrong path to begin with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   time = input(put(date,z4.),hhmmss4.);
   format time time5.;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 May 2018 20:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-variable-into-SAS-time-variable/m-p/464577#M118460</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-23T20:59:14Z</dc:date>
    </item>
  </channel>
</rss>

