<?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 Words in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-Words/m-p/694432#M211775</link>
    <description>&lt;P&gt;This keeps the string until a comma or 2 uppercase letters are encountered:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  input CITY :&amp;amp; $40.;
cards;
Ft.Belvoir, VA
Annapolis NHC, MD 
Camp Pendleton NH, CA 
run;

data WANT;
  set HAVE;
  LOCATION = prxchange('s/(.*?)(,|([A-Z]{2})).*/Location \1/',1,CITY);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" width="385px" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col" width="188px"&gt;CITY&lt;/TH&gt;
&lt;TH class="l header" scope="col" width="196px"&gt;LOCATION&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="188px" class="l data"&gt;Ft.Belvoir, VA&lt;/TD&gt;
&lt;TD width="196px" class="l data"&gt;Location Ft.Belvoir&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="188px" class="l data"&gt;Annapolis NHC, MD&lt;/TD&gt;
&lt;TD width="196px" class="l data"&gt;Location Annapolis&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="188px" class="l data"&gt;Camp Pendleton NH, CA&lt;/TD&gt;
&lt;TD width="196px" class="l data"&gt;Location Camp Pendleton&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Oct 2020 04:33:02 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-10-27T04:33:02Z</dc:date>
    <item>
      <title>Remove Words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Words/m-p/694397#M211768</link>
      <description>&lt;P&gt;Please forgive me, I have been trying to figure this out for sometime now and I have read the various solutions related to my question, in this forum, but I am still unable to come up with a solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My problem is I have a dataset like below (also attached) with hundreds of observations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="162"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="162"&gt;Ft.Belvoir, VA&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Annapolis NHC, MD&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Camp Pendleton NH, CA&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I would like to do is keep just the name part and add the word location in the front. I would like to end up with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Location Ft. Belvoir&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Location Annapolis&lt;/P&gt;
&lt;P&gt;Location Camp Pendleton&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could someone assist me with this please?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 00:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Words/m-p/694397#M211768</guid>
      <dc:creator>luvscandy27</dc:creator>
      <dc:date>2020-10-27T00:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Words/m-p/694400#M211769</link>
      <description>&lt;P&gt;This is made difficult because you have no clear definition of what the "name part" is.&lt;/P&gt;
&lt;P&gt;In this example I assumed you wanted every up to the first occurrence of "NH" or the first comma.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines dlm="-";
  length city $ 40;
  input city $;
datalines;
Ft.Belvoir, VA
Annapolis NHC, MD 
Camp Pendleton NH, CA 
;
run;


data want(drop=place);
  set have;
  if index(city,"NH") then place = substr(city,1,index(city,"NH")-1);
  else place = scan(city,1,", ");
  location = catx(" ","Location",place);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Oct 2020 00:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Words/m-p/694400#M211769</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-10-27T00:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Words/m-p/694432#M211775</link>
      <description>&lt;P&gt;This keeps the string until a comma or 2 uppercase letters are encountered:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  input CITY :&amp;amp; $40.;
cards;
Ft.Belvoir, VA
Annapolis NHC, MD 
Camp Pendleton NH, CA 
run;

data WANT;
  set HAVE;
  LOCATION = prxchange('s/(.*?)(,|([A-Z]{2})).*/Location \1/',1,CITY);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" width="385px" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col" width="188px"&gt;CITY&lt;/TH&gt;
&lt;TH class="l header" scope="col" width="196px"&gt;LOCATION&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="188px" class="l data"&gt;Ft.Belvoir, VA&lt;/TD&gt;
&lt;TD width="196px" class="l data"&gt;Location Ft.Belvoir&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="188px" class="l data"&gt;Annapolis NHC, MD&lt;/TD&gt;
&lt;TD width="196px" class="l data"&gt;Location Annapolis&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="188px" class="l data"&gt;Camp Pendleton NH, CA&lt;/TD&gt;
&lt;TD width="196px" class="l data"&gt;Location Camp Pendleton&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 04:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Words/m-p/694432#M211775</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-10-27T04:33:02Z</dc:date>
    </item>
  </channel>
</rss>

