<?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: Remove character is a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384886#M91992</link>
    <description>&lt;P&gt;Thanks that seems to work fine. Just going through this poor quality data. Would you know how to deal with records like the below as part of the same syntax:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Have&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;A IAN GILES&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Want&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IAN GILES&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I should be then good to go to split the names into forenames and surnames and then create a matchkey to match data in different files. Many thanks for your help.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Aug 2017 08:32:49 GMT</pubDate>
    <dc:creator>cmoore</dc:creator>
    <dc:date>2017-08-02T08:32:49Z</dc:date>
    <item>
      <title>Remove character is a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384879#M91988</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a field that contains a string in many different formats. What I want to do is remove the last character in a string. Please see below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Have&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;input name $1-24;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;cards;&lt;BR /&gt;&lt;STRONG&gt;BANGE RICHARD M&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;AARON J BOWLER&lt;/STRONG&gt;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data two;&lt;BR /&gt;set one;&lt;BR /&gt;length new_name $24;&lt;BR /&gt;new_name=substr(name, 1, length(name)-1);&lt;BR /&gt;run;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;proc print;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Want&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;BANGE RICHARD&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AARON J BOWLER&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The code above works for the top record bit incorrecly removes a character from Bowler. Is there a simpe way to remove the last character where its not attached to another string but ignore full words?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 08:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384879#M91988</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-08-02T08:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Remove character is a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384882#M91990</link>
      <description>&lt;P&gt;Well an if could sort that:&lt;/P&gt;
&lt;PRE&gt;data one; &lt;BR /&gt;input name $1-24; &lt;BR /&gt;cards;&lt;BR /&gt;BANGE RICHARD M&lt;BR /&gt;AARON J BOWLER&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data two;&lt;BR /&gt; set one;&lt;BR /&gt; length new_name $24;&lt;BR /&gt; new_name=ifc(char(name,lengthn(name)-1)=" ",substr(name,1,lengthn(name)-1),name);&lt;BR /&gt;run; 
&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Aug 2017 08:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384882#M91990</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-02T08:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Remove character is a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384885#M91991</link>
      <description>&lt;P&gt;You can try using a coditional statement&amp;nbsp;:-&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;input name $1-24;&lt;BR /&gt;cards;&lt;BR /&gt;BANGE RICHARD M&lt;BR /&gt;AARON J BOWLER&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data two;&lt;BR /&gt;set one;&lt;BR /&gt;length new_name $24;&lt;/P&gt;&lt;P&gt;if length(scan(reverse(name),1)) = 1 then&lt;BR /&gt;new_name = substr(name, 1, length(name)-1);&lt;BR /&gt;else new_name = name;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do let me know for your suggestions.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 08:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384885#M91991</guid>
      <dc:creator>Gautam0072</dc:creator>
      <dc:date>2017-08-02T08:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: Remove character is a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384886#M91992</link>
      <description>&lt;P&gt;Thanks that seems to work fine. Just going through this poor quality data. Would you know how to deal with records like the below as part of the same syntax:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Have&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;A IAN GILES&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Want&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IAN GILES&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I should be then good to go to split the names into forenames and surnames and then create a matchkey to match data in different files. Many thanks for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 08:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384886#M91992</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-08-02T08:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Remove character is a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384887#M91993</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;according to me you can again use the same set of conditional statements. with a few changes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;input name $1-24;&lt;BR /&gt;cards;&lt;BR /&gt;BANGE RICHARD M&lt;BR /&gt;AARON J BOWLER&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data two;&lt;BR /&gt;set one;&lt;BR /&gt;length new_name $24;&lt;/P&gt;&lt;P&gt;if length(scan(name,1)) = 1 then&lt;BR /&gt;new_name = substr(name, 3);&lt;BR /&gt;else new_name = name;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;guess that would work. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 08:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384887#M91993</guid>
      <dc:creator>Gautam0072</dc:creator>
      <dc:date>2017-08-02T08:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Remove character is a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384889#M91995</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I like this suggestion also. How would you cleanse the name "A IAN GILES" to "IAN GILES" in the same syntax? Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 08:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384889#M91995</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-08-02T08:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Remove character is a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384890#M91996</link>
      <description>&lt;PRE&gt;data two;&lt;BR /&gt; set one;&lt;BR /&gt; length new_name $24;&lt;BR /&gt; new_name=ifc(char(name,lengthn(name)-1)=" ",substr(name,1,lengthn(name)-1),name);&lt;BR /&gt; new_name=ifc(char(new_name,2)=" ",substr(new_name,3),new_name);&lt;BR /&gt;run; &lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Aug 2017 08:41:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384890#M91996</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-02T08:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Remove character is a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384897#M92001</link>
      <description>&lt;P&gt;Alternatively you could try the perl regular expression which will achieve the expected output from a single line code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one; 
input name $1-24; 
&lt;STRONG&gt;newname=prxchange('s/^\w\s|\w$/ /',-1,strip(name));&lt;/STRONG&gt;
cards;
BANGE RICHARD M
AARON J BOWLER
A IAN GILES
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Aug 2017 10:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-character-is-a-string/m-p/384897#M92001</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-08-02T10:30:52Z</dc:date>
    </item>
  </channel>
</rss>

