<?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 Substring issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Substring-issue/m-p/504338#M134947</link>
    <description>I have a table&lt;BR /&gt;Pro sql;&lt;BR /&gt;Create table settle4 as&lt;BR /&gt;Id,&lt;BR /&gt;Datetime,&lt;BR /&gt;Substr(put(datetime,16.),12,21) as timestamp&lt;BR /&gt;From table1);&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;The output is&lt;BR /&gt;15544&lt;BR /&gt;15595&lt;BR /&gt;The data looks&lt;BR /&gt;13oct18:02:05:44&lt;BR /&gt;13oct18:02:06:35&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I would want to extract the hour only</description>
    <pubDate>Mon, 15 Oct 2018 14:34:52 GMT</pubDate>
    <dc:creator>Gil_</dc:creator>
    <dc:date>2018-10-15T14:34:52Z</dc:date>
    <item>
      <title>Substring issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substring-issue/m-p/504338#M134947</link>
      <description>I have a table&lt;BR /&gt;Pro sql;&lt;BR /&gt;Create table settle4 as&lt;BR /&gt;Id,&lt;BR /&gt;Datetime,&lt;BR /&gt;Substr(put(datetime,16.),12,21) as timestamp&lt;BR /&gt;From table1);&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;The output is&lt;BR /&gt;15544&lt;BR /&gt;15595&lt;BR /&gt;The data looks&lt;BR /&gt;13oct18:02:05:44&lt;BR /&gt;13oct18:02:06:35&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I would want to extract the hour only</description>
      <pubDate>Mon, 15 Oct 2018 14:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substring-issue/m-p/504338#M134947</guid>
      <dc:creator>Gil_</dc:creator>
      <dc:date>2018-10-15T14:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Substring issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substring-issue/m-p/504341#M134948</link>
      <description>&lt;P&gt;have you tried hour function i,e&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hour(datetime)&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 14:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substring-issue/m-p/504341#M134948</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T14:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Substring issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substring-issue/m-p/504372#M134959</link>
      <description>&lt;P&gt;A datetime value is a&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;count of seconds&lt;/STRONG&gt;&lt;/EM&gt;. Using a simple numeric format will display the raw number of seconds as a string, and the substr() then shows the values you posted. SAS provides functions to extract the date- and timepart, and functions to extract further sub-divisions (eg minutes or days) from those.&lt;/P&gt;
&lt;P&gt;You find these functions in the documentation for data step programming on documentation.sas.com.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 16:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substring-issue/m-p/504372#M134959</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-15T16:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Substring issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substring-issue/m-p/504455#M134994</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/117620"&gt;@Gil_&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I have a table&lt;BR /&gt;Pro sql;&lt;BR /&gt;Create table settle4 as&lt;BR /&gt;Id,&lt;BR /&gt;Datetime,&lt;BR /&gt;Substr(put(datetime,16.),12,21) as timestamp&lt;BR /&gt;From table1);&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;The output is&lt;BR /&gt;15544&lt;BR /&gt;15595&lt;BR /&gt;The data looks&lt;BR /&gt;13oct18:02:05:44&lt;BR /&gt;13oct18:02:06:35&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I would want to extract the hour only&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;This line of code&lt;/P&gt;
&lt;PRE&gt;Substr(put(datetime,16.),12,21) as timestamp&lt;/PRE&gt;
&lt;P&gt;Should generate a message like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Invalid argument 3 to function SUBSTR. Missing values may be generated.

&lt;/PRE&gt;
&lt;P&gt;as you are asking for more characters, 21, than would exist (put(datetime,16.) would have a maximum of 16 characters).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which should indicate that you are doing something incorrectly. Even using a DATETIME16. format you wouldn't want to start at position 12.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substring-issue/m-p/504455#M134994</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-15T19:44:33Z</dc:date>
    </item>
  </channel>
</rss>

