<?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 ending &amp;quot;-XX&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672921#M202310</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input str $40.;
cards;
TUXEDO PARTNERS INC-AT
KEYES HOWARD AUTO DLRHSPS-PX
SPRING HILL FORD INC-CH
MEGASTAR INC
BRANDON CHRY-PLYM INC-TM
;
run;
data want;
set have;
rev_str=(strip(reverse(str)));
new_str=strip(reverse(substr(rev_str,index(rev_str,'-')+1)));
drop rev_str;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Jul 2020 17:18:38 GMT</pubDate>
    <dc:creator>singhsahab</dc:creator>
    <dc:date>2020-07-28T17:18:38Z</dc:date>
    <item>
      <title>remove ending "-XX"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672879#M202280</link>
      <description>&lt;P&gt;I have a variable with values like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TUXEDO PARTNERS INC-AT
KEYES HOWARD AUTO DLRHSPS-PX
SPRING HILL FORD INC-CH
MEGASTAR INC
BRANDON CHRY-PLYM INC-TM&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ending "-XX" is the city abbreviations. I want to remove this part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It can't be coded as removing characters after "-" because "-" can appear in the middle of the string. Or remove the last three characters because some values don't have ending "-XX".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips on dealing with this situation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 15:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672879#M202280</guid>
      <dc:creator>jl2978</dc:creator>
      <dc:date>2020-07-28T15:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: remove ending "-XX"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672884#M202283</link>
      <description>Check if the 3rd to last character is a - and then remove it?&lt;BR /&gt;&lt;BR /&gt;if substr(variable, length(variable)-3, 1) = '-' then want = substr(variable, length(variable)-3);&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Jul 2020 15:31:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672884#M202283</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-28T15:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: remove ending "-XX"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672885#M202284</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input str $40.;
cards;
TUXEDO PARTNERS INC-AT
KEYES HOWARD AUTO DLRHSPS-PX
SPRING HILL FORD INC-CH
MEGASTAR INC
BRANDON CHRY-PLYM INC-TM
;

data want;
 set have;
 _n_=findc(str,'-','b');
 if _n_ then want=substr(str,1,_n_);
 else want=str;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jul 2020 15:33:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672885#M202284</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-07-28T15:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: remove ending "-XX"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672914#M202305</link>
      <description>&lt;P&gt;I hope you did not mean _n_ &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 16:40:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672914#M202305</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-07-28T16:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: remove ending "-XX"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672919#M202308</link>
      <description>&lt;P&gt;Using PRXMATCH to determine if the string ends with "-XX":&lt;/P&gt;
&lt;PRE&gt;data have;
    input str $40.;
    cards;
    TUXEDO PARTNERS INC-AT
    KEYES HOWARD AUTO DLRHSPS-PX
    SPRING HILL FORD INC-CH
    MEGASTAR INC
    BRANDON CHRY-PLYM INC-TM
    TEST-ABC-DEF-XX
;
run;

data want;
   set have;
   if prxmatch('/(\w+)-\w\w\s*$/', str)
       then want = substr(str, 1, length(str)-3);
   else want=str;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jul 2020 17:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672919#M202308</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-07-28T17:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: remove ending "-XX"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672921#M202310</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input str $40.;
cards;
TUXEDO PARTNERS INC-AT
KEYES HOWARD AUTO DLRHSPS-PX
SPRING HILL FORD INC-CH
MEGASTAR INC
BRANDON CHRY-PLYM INC-TM
;
run;
data want;
set have;
rev_str=(strip(reverse(str)));
new_str=strip(reverse(substr(rev_str,index(rev_str,'-')+1)));
drop rev_str;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jul 2020 17:18:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672921#M202310</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2020-07-28T17:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: remove ending "-XX"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672976#M202331</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214340"&gt;@smantha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I hope you did not mean _n_ &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; seems to like playing with fire and often uses a variable _n_ instead of considering the possible confusion with the SAS automatic variable of the same name.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 22:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/672976#M202331</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-28T22:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: remove ending "-XX"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/673023#M202372</link>
      <description>Most likely picked up from some of the older programmers I think but not something I would recommend doing at all &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 29 Jul 2020 02:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/673023#M202372</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-29T02:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: remove ending "-XX"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/673091#M202418</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input str $40.;

want=prxchange('s/-\w\w$//',-1,strip(str));

cards;
TUXEDO PARTNERS INC-AT
KEYES HOWARD AUTO DLRHSPS-PX
SPRING HILL FORD INC-CH
MEGASTAR INC
BRANDON CHRY-PLYM INC-TM
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Jul 2020 12:21:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/673091#M202418</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-07-29T12:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: remove ending "-XX"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/673093#M202420</link>
      <description>&lt;PRE&gt;data have;
input str $40.;

want=prxchange('s/-\w\w\s*$//',1,str);

cards;
TUXEDO PARTNERS INC-AT
KEYES HOWARD AUTO DLRHSPS-PX
SPRING HILL FORD INC-CH
MEGASTAR INC
BRANDON CHRY-PLYM INC-TM
;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Jul 2020 12:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-ending-quot-XX-quot/m-p/673093#M202420</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-07-29T12:26:11Z</dc:date>
    </item>
  </channel>
</rss>

