<?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 insert a colon in between already existing observations? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-colon-in-between-already-existing-observations/m-p/453644#M114660</link>
    <description>&lt;P&gt;Use SUBSTR() to get the last two characters and then SUBSTR() to get the first or first two characters.&lt;/P&gt;
&lt;P&gt;If the length is less than 4 it may be worth adding the leading zero.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want another character variable though, or a SAS time?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    data want;
    input have $;
    if length(have) &amp;lt; 4 then have = catt('0', have);
    hours = substr(have, 1, 2);
    minutes = substr(have, 3, 2);
    time_char = catx(":", hours, minutes);
    time_sas = input(time_char, time.);
    format time_sas time.;
    cards;
    423
    1423
    830
    1204
    ;
    run;

    proc print data=want;
    run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/201126"&gt;@Akshayvrata&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have to perform the hour function on a variable in which observations display like (515, 815, etc.) though it has to be like (5:15, 8:15, etc.). Now how can I insert colon in my observations so that they appear like later ones.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i know that i have to change the format of the variable to character then only I can add colon.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So please tell me what function I can use to solve this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Apr 2018 16:33:39 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-04-12T16:33:39Z</dc:date>
    <item>
      <title>How to insert a colon in between already existing observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-colon-in-between-already-existing-observations/m-p/453635#M114656</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have to perform the hour function on a variable in which observations display like (515, 815, etc.) though it has to be like (5:15, 8:15, etc.). Now how can I insert colon in my observations so that they appear like later ones.&amp;nbsp;&lt;/P&gt;&lt;P&gt;i know that i have to change the format of the variable to character then only I can add colon.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So please tell me what function I can use to solve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 16:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-colon-in-between-already-existing-observations/m-p/453635#M114656</guid>
      <dc:creator>Akshayvrata</dc:creator>
      <dc:date>2018-04-12T16:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a colon in between already existing observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-colon-in-between-already-existing-observations/m-p/453640#M114658</link>
      <description>&lt;P&gt;So you have a numeric field "515" (five hundred fifteen), and it represents 5 hours 15 minutes? I would split this off like so:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;data want;
  timevar=515;
  minutes = mod(timevar, 100);
  hours = floor(divide(timevar,100));
  final_var = hms(hours,minutes,0);
  format final_var hhmm5.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This makes it a numeric date variable displaying correctly.&amp;nbsp; But you could&amp;nbsp;also use PUT to make this character.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 16:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-colon-in-between-already-existing-observations/m-p/453640#M114658</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2018-04-12T16:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert a colon in between already existing observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-colon-in-between-already-existing-observations/m-p/453644#M114660</link>
      <description>&lt;P&gt;Use SUBSTR() to get the last two characters and then SUBSTR() to get the first or first two characters.&lt;/P&gt;
&lt;P&gt;If the length is less than 4 it may be worth adding the leading zero.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want another character variable though, or a SAS time?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    data want;
    input have $;
    if length(have) &amp;lt; 4 then have = catt('0', have);
    hours = substr(have, 1, 2);
    minutes = substr(have, 3, 2);
    time_char = catx(":", hours, minutes);
    time_sas = input(time_char, time.);
    format time_sas time.;
    cards;
    423
    1423
    830
    1204
    ;
    run;

    proc print data=want;
    run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/201126"&gt;@Akshayvrata&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have to perform the hour function on a variable in which observations display like (515, 815, etc.) though it has to be like (5:15, 8:15, etc.). Now how can I insert colon in my observations so that they appear like later ones.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i know that i have to change the format of the variable to character then only I can add colon.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So please tell me what function I can use to solve this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 16:33:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-insert-a-colon-in-between-already-existing-observations/m-p/453644#M114660</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-12T16:33:39Z</dc:date>
    </item>
  </channel>
</rss>

