<?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: Substr with length in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751030#M236338</link>
    <description>&lt;P&gt;What is the incorrect result that you are getting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide a small portion of your data set following &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;? Because obviously when you manually type a character string in a line of text, sometimes the full information is lost about what this character string really is (for example there may be non-printing characters).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I want the result only using susbstr function.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I reserve the right to give other answers,&amp;nbsp;to propose simpler methods, especially for the benefit of others who might be reading along, and I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;has nailed it.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Jun 2021 18:56:43 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-06-29T18:56:43Z</dc:date>
    <item>
      <title>Substr with length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751020#M236333</link>
      <description>&lt;P&gt;I've one variable called CRE and it has value like &lt;STRONG&gt;MIN_[NDIP]_2&lt;/STRONG&gt;. Now I want to filter only the values &lt;STRONG&gt;[NDIP]&lt;/STRONG&gt; using substr function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I tried with the following, it's not producing the desired result. Any help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;substr(cre,5,length(cre)-2)&lt;/PRE&gt;
&lt;P&gt;I want the result only using susbstr function.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 17:27:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751020#M236333</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-06-29T17:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Substr with length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751028#M236336</link>
      <description>&lt;P&gt;scan(cre, 2, "_")&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 18:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751028#M236336</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-06-29T18:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Substr with length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751030#M236338</link>
      <description>&lt;P&gt;What is the incorrect result that you are getting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide a small portion of your data set following &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;? Because obviously when you manually type a character string in a line of text, sometimes the full information is lost about what this character string really is (for example there may be non-printing characters).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I want the result only using susbstr function.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I reserve the right to give other answers,&amp;nbsp;to propose simpler methods, especially for the benefit of others who might be reading along, and I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;has nailed it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 18:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751030#M236338</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-29T18:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Substr with length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751031#M236339</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've one variable called CRE and it has value like &lt;STRONG&gt;MIN_[NDIP]_2&lt;/STRONG&gt;. Now I want to filter only the values &lt;STRONG&gt;[NDIP]&lt;/STRONG&gt; using substr function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I tried with the following, it's not producing the desired result. Any help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;substr(cre,5,length(cre)-2)&lt;/PRE&gt;
&lt;P&gt;I want the result only using susbstr function.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your arithmetic is wrong.&amp;nbsp; You need also subtract the 4 characters you skipped by starting in column 5.&lt;/P&gt;
&lt;PRE&gt;733  data test;
734    x='MIN_[NDIP]_2    ';
735    len=length(x);
736    want=substr(x,5,len-4-2);
737    put (_all_) (=/);
738  run;

x=MIN_[NDIP]_2 
len=12 
want=[NDIP]
&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Jun 2021 18:15:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751031#M236339</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-29T18:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Substr with length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751039#M236346</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;I want the result only using susbstr function.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Maxim 14.&lt;/P&gt;
&lt;P&gt;Maxim 14.&lt;/P&gt;
&lt;P&gt;Maxim 14.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 18:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-with-length/m-p/751039#M236346</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-29T18:53:01Z</dc:date>
    </item>
  </channel>
</rss>

