<?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: String manipulation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596524#M171763</link>
    <description>&lt;P&gt;A little play with length() and substr():&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input string $30.;
datalines;
09120192019 0800000  C
047        X4540001  C
013        X4512000  C
02020192019 0919000  C
;

data want;
set have;
if substr(string,length(string)-1,2) = ' C'
then string = substr(string,1,length(string)-2);
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;      string

09120192019 0800000
047        X4540001
013        X4512000
02020192019 0919000
&lt;/PRE&gt;</description>
    <pubDate>Tue, 15 Oct 2019 13:46:11 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-10-15T13:46:11Z</dc:date>
    <item>
      <title>String manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596518#M171759</link>
      <description>&lt;P&gt;I have the following strings. I want to get rid of the C at the end. This is because another file that has this variable does not contain the C and when it is merged creates problem. I want to get rid of the C at the end.&lt;/P&gt;&lt;P&gt;09120192019 0800000&amp;nbsp; C&lt;/P&gt;&lt;P&gt;047&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X4540001&amp;nbsp; C&lt;/P&gt;&lt;P&gt;013&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X4512000&amp;nbsp; C&lt;/P&gt;&lt;P&gt;02020192019 0919000&amp;nbsp; C&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2019 13:40:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596518#M171759</guid>
      <dc:creator>mauri0623</dc:creator>
      <dc:date>2019-10-15T13:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: String manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596520#M171761</link>
      <description>&lt;P&gt;So if the last character of the string is 'C' then you want to get rid of it? But not if it is an 'A' for example?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2019 13:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596520#M171761</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-15T13:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: String manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596524#M171763</link>
      <description>&lt;P&gt;A little play with length() and substr():&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input string $30.;
datalines;
09120192019 0800000  C
047        X4540001  C
013        X4512000  C
02020192019 0919000  C
;

data want;
set have;
if substr(string,length(string)-1,2) = ' C'
then string = substr(string,1,length(string)-2);
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;      string

09120192019 0800000
047        X4540001
013        X4512000
02020192019 0919000
&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Oct 2019 13:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596524#M171763</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-15T13:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: String manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596526#M171765</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input string $30.;
datalines;
09120192019 0800000  C
047        X4540001  C
013        X4512000  C
02020192019 0919000  C
;


data want;
set have;
want=substr(string,1,findc(string,'c','ib')-1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Oct 2019 13:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596526#M171765</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-10-15T13:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: String manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596555#M171778</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/181538"&gt;@mauri0623&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have the following strings. I want to get rid of the C at the end. This is because another file that has this variable does not contain the C and when it is merged creates problem. I want to get rid of the C at the end.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Maybe you don't have to get rid of the trailing "C".&amp;nbsp; Since the other variable would match everything but the trailing C, you could match based on the "EQT"&amp;nbsp; (equal-truncated) operator, as in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
  input id  @13 matchval $11. ;
datalines;
09120192019 0800000  C
047         X4540001  C
013         X4512000  C
02020192019 0919000  C
run;

data table2;
  input name $4.  matchval $11.;
  put (_all_) (=);
datalines;
DAVE 0800000
MARK X4512000
ALEX ABCDEF
run;
proc sql;
  create table want as select t1.*,t2.name
  from table1 as t1 inner join table2 as t2
  on t1.matchval EQT t2.matchval;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Oct 2019 15:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-manipulation/m-p/596555#M171778</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-15T15:05:30Z</dc:date>
    </item>
  </channel>
</rss>

