<?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 the last word of a string. Special case. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559373#M10292</link>
    <description>&lt;P&gt;After your answer, I edited the first message to add the case "1.2" from "1.2.4".&lt;BR /&gt;The rule is:&lt;BR /&gt;Remove the last number before the last "." and if it exists the letter just before the last number and the "." just before the letter.&lt;BR /&gt;I am thinking about retrieve the position &amp;amp; length of last-1 word saying that letters and "." are delimiters and remove every character that is at le right of the position+length.&lt;/P&gt;</description>
    <pubDate>Thu, 16 May 2019 15:51:52 GMT</pubDate>
    <dc:creator>Hugo_B</dc:creator>
    <dc:date>2019-05-16T15:51:52Z</dc:date>
    <item>
      <title>Remove the last word of a string. Special case.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559342#M10280</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this subject has been heavily present on various forums, but my case is a little bit special:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a character variable that represents the position of an element in a tree structure.&lt;/P&gt;&lt;P&gt;Here are some possible values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;1.1&lt;/P&gt;&lt;P&gt;1.1.1&lt;/P&gt;&lt;P&gt;1.2&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;1.2.12&lt;/P&gt;&lt;P&gt;1.3.a.3&lt;/P&gt;&lt;P&gt;1.3.3.a.2.2&lt;/P&gt;&lt;P&gt;1.3.3.b.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"1" represents the root.&lt;/P&gt;&lt;P&gt;Imagine that 1.2 is a node and 1.2.1 &amp;amp; 1.2.2 represent the two branches/paths. A letter in a the string like in "1.1.a.1" &amp;amp; "1.1.b.1" represents a choice between path a or b.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is : How to retrieve the parent node from the branches ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I want to:&lt;/P&gt;&lt;P&gt;retrieve "1.3.3" from the string "1.3.3.b.11"&lt;/P&gt;&lt;P&gt;retrieve "1.3" from "1.3.a.3"&lt;/P&gt;&lt;P&gt;or retrieve 1.2.3 from 1.2.3.5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried several methods and I managed to get the last word of the string and its position using SCAN Function and defining '.' and letters as delimiters ... but how to remove the last word + the possible '.' or letters trailing. Without removing the ones that are inside the string ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am thinking about retrieving the length position of the last-1 word of the string and remove erveything after this point, but I didn't find the good method yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this is clear. Thank you in advance for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 15:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559342#M10280</guid>
      <dc:creator>Hugo_B</dc:creator>
      <dc:date>2019-05-16T15:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Remove the last word of a string. Special case.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559350#M10281</link>
      <description>&lt;P&gt;Use the &lt;A href="https://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0s3647o5kwnnin0zcht0s5p9f1l.htm&amp;amp;locale=en" target="_self"&gt;ANYALPHA function&lt;/A&gt; to find the first occurrence of a letter, then take all text to the left.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 15:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559350#M10281</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-16T15:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Remove the last word of a string. Special case.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559360#M10285</link>
      <description>&lt;P&gt;Hello thank you for your anwser,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It wasn't very clear in the message (I edited it) but it's not only letters:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want :&lt;/P&gt;&lt;P&gt;"1.2" from "1.2.4"&lt;/P&gt;&lt;P&gt;"1.2" from "1.2.b.3"&lt;/P&gt;&lt;P&gt;"1.3.a.3" from "1.3.a.3.b.4"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Letters can appear several times if the tree is tall.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 15:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559360#M10285</guid>
      <dc:creator>Hugo_B</dc:creator>
      <dc:date>2019-05-16T15:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Remove the last word of a string. Special case.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559367#M10288</link>
      <description>&lt;P&gt;As far as I can see, you have not stated the actual rule to use for the case&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;"1.2" from "1.2.4"&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What is the rule you are using here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;With regards to multiple letters, what is the actual rule being used here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;"1.3.a.3" from "1.3.a.3.b.4"&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And what is the rule used here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;retrieve "1.3.3" from the string "1.3.3.b.11"&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is there a description of the entire process so that we don't have to generalize from a few examples?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 15:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559367#M10288</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-16T15:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Remove the last word of a string. Special case.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559373#M10292</link>
      <description>&lt;P&gt;After your answer, I edited the first message to add the case "1.2" from "1.2.4".&lt;BR /&gt;The rule is:&lt;BR /&gt;Remove the last number before the last "." and if it exists the letter just before the last number and the "." just before the letter.&lt;BR /&gt;I am thinking about retrieve the position &amp;amp; length of last-1 word saying that letters and "." are delimiters and remove every character that is at le right of the position+length.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 15:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559373#M10292</guid>
      <dc:creator>Hugo_B</dc:creator>
      <dc:date>2019-05-16T15:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Remove the last word of a string. Special case.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559392#M10298</link>
      <description>&lt;P&gt;I managed to find this solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CALL SCAN( string, -2, last_pos, last_length, '.', 'l')&lt;/P&gt;&lt;P&gt;want = substrn( string, 1, last_pos + last_length -1)&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 16:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-the-last-word-of-a-string-Special-case/m-p/559392#M10298</guid>
      <dc:creator>Hugo_B</dc:creator>
      <dc:date>2019-05-16T16:16:09Z</dc:date>
    </item>
  </channel>
</rss>

