<?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: delete / cut text variable at the end of string with certain rule in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/delete-cut-text-variable-at-the-end-of-string-with-certain-rule/m-p/333035#M272096</link>
    <description>It works nicely.&lt;BR /&gt;Thank you.&lt;BR /&gt;HC</description>
    <pubDate>Wed, 15 Feb 2017 15:02:09 GMT</pubDate>
    <dc:creator>hhchenfx</dc:creator>
    <dc:date>2017-02-15T15:02:09Z</dc:date>
    <item>
      <title>delete / cut text variable at the end of string with certain rule</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-cut-text-variable-at-the-end-of-string-with-certain-rule/m-p/332897#M272093</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a &lt;SPAN class="lia-search-match-lithium"&gt;variable&lt;/SPAN&gt; of &lt;SPAN class="lia-search-match-lithium"&gt;text&lt;/SPAN&gt; "name" with some record follow the rule.&lt;/P&gt;
&lt;P&gt;As you see, the records are&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;value123&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;value&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;value&lt;FONT color="#FF0000"&gt;_lg3&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;value_t1&lt;FONT color="#FF0000"&gt;_lg6&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;value&lt;FONT color="#FF0000"&gt;_lg12&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;value_3_ab&lt;FONT color="#FF0000"&gt;_lg3&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want all record with the lg at the end to be delete anything after the "_lg" including the "_lg" itself.&lt;/P&gt;
&lt;P&gt;it only appear at the end if there is any "_lg".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the output should be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;value123&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;value_t1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;value_3_ab&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any help is very much appreciated.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;HHC&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;&lt;BR /&gt;input name $;&lt;BR /&gt;datalines;&lt;BR /&gt;value123&lt;BR /&gt;value&lt;BR /&gt;value_lg3&lt;BR /&gt;value_t1_lg6&lt;BR /&gt;value_lg12&lt;BR /&gt;value_3_ab_lg3&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 04:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-cut-text-variable-at-the-end-of-string-with-certain-rule/m-p/332897#M272093</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-02-15T04:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: delete / cut text variable at the end of string with certain rule</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-cut-text-variable-at-the-end-of-string-with-certain-rule/m-p/332916#M272094</link>
      <description>&lt;P&gt;Use next code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ix = index(name,'_lg');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ix&amp;gt;0 then name = substr(name,1,ix-1);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 07:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-cut-text-variable-at-the-end-of-string-with-certain-rule/m-p/332916#M272094</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-15T07:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: delete / cut text variable at the end of string with certain rule</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-cut-text-variable-at-the-end-of-string-with-certain-rule/m-p/332938#M272095</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $20.;
want=prxchange('s/\_lg\d+\s*$//i',1,name);
datalines;
value123
value
value_lg3
value_t1_lg6
value_lg12
value_3_ab_lg3
;
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2017 10:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-cut-text-variable-at-the-end-of-string-with-certain-rule/m-p/332938#M272095</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-02-15T10:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: delete / cut text variable at the end of string with certain rule</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-cut-text-variable-at-the-end-of-string-with-certain-rule/m-p/333035#M272096</link>
      <description>It works nicely.&lt;BR /&gt;Thank you.&lt;BR /&gt;HC</description>
      <pubDate>Wed, 15 Feb 2017 15:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-cut-text-variable-at-the-end-of-string-with-certain-rule/m-p/333035#M272096</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-02-15T15:02:09Z</dc:date>
    </item>
  </channel>
</rss>

