<?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: Using the SUBSTRING function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-the-SUBSTRING-function/m-p/290346#M60071</link>
    <description>&lt;P&gt;Use the CHAR() function instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CHAR(string, position)&lt;/P&gt;
&lt;P&gt;String -&amp;gt; always the same&lt;/P&gt;
&lt;P&gt;position -&amp;gt; loop counter, in this case i&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SUBSTR(STRING, start, length)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;String -&amp;gt; Should always be the same&lt;/P&gt;
&lt;P&gt;Start -&amp;gt; loop counter, in this case i&lt;/P&gt;
&lt;P&gt;length -&amp;gt; always 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;D&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;substr&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(STRING_VARIABLE&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; i&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Aug 2016 22:38:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-08-08T22:38:17Z</dc:date>
    <item>
      <title>Using the SUBSTRING function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-SUBSTRING-function/m-p/290344#M60069</link>
      <description>&lt;P&gt;I am trying to use the SUBSTRING function to extract a single character from a 60 character string. I want to create 60 new variables (D1, D2, etc.) each containing a sequential digit in the string. In other words, D1 contains the first digit of the string. D2 contains the second digit of the string. D3 contains the 3rd digit of the string, etc. There are multiple observations in the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code is inadequate, but pasted below for reference. Thanks for any ideas you may have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want&amp;nbsp;(drop=i);
set have;

array D(60);
array seq(60);

do i = 1 to 60;
D[i] = substr(seq[i], 1, 1);
* How do I write this so it will jump from the first position to the next position in the sequence automatically?
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 22:27:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-SUBSTRING-function/m-p/290344#M60069</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2016-08-08T22:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using the SUBSTRING function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-SUBSTRING-function/m-p/290346#M60071</link>
      <description>&lt;P&gt;Use the CHAR() function instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CHAR(string, position)&lt;/P&gt;
&lt;P&gt;String -&amp;gt; always the same&lt;/P&gt;
&lt;P&gt;position -&amp;gt; loop counter, in this case i&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SUBSTR(STRING, start, length)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;String -&amp;gt; Should always be the same&lt;/P&gt;
&lt;P&gt;Start -&amp;gt; loop counter, in this case i&lt;/P&gt;
&lt;P&gt;length -&amp;gt; always 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;D&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;substr&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(STRING_VARIABLE&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; i&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Aug 2016 22:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-SUBSTRING-function/m-p/290346#M60071</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-08T22:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using the SUBSTRING function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-SUBSTRING-function/m-p/290355#M60077</link>
      <description>&lt;P&gt;One more item you might want to attend to ... assign a length to the new variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array D {60} $ 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, the length of the new variables will default to the same length as the original incoming character string.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 23:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-SUBSTRING-function/m-p/290355#M60077</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-08T23:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using the SUBSTRING function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-SUBSTRING-function/m-p/290390#M60092</link>
      <description>&lt;P&gt;Could I ask why. &amp;nbsp;It is rarely beneficial to create many variables such as you are doing, in terms of programming. &amp;nbsp;For all your subsequent programming you then need to know how many there are, which could vary. &amp;nbsp;Are you doing some sort of agregates or maths on them, as you can probably do that straight from the string (or if necessary output one row per character). &amp;nbsp;Would make you life much easier.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 08:43:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-SUBSTRING-function/m-p/290390#M60092</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-09T08:43:21Z</dc:date>
    </item>
  </channel>
</rss>

