<?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: how to remove the text after a specific character/words in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613505#M18429</link>
    <description>&lt;P&gt;Your word "Office" is always followed by a "&amp;gt;". Can you use that as the delimiter? Then it would be a simple call of scan().&lt;/P&gt;</description>
    <pubDate>Mon, 23 Dec 2019 10:31:25 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-12-23T10:31:25Z</dc:date>
    <item>
      <title>how to remove the text after a specific character/words</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613500#M18428</link>
      <description>&lt;P&gt;Hi Mate,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your advice how can I remove the text after a specific character/words&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;House and Office &amp;gt; Lighting &amp;gt; Floor Lamps&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Building and&amp;nbsp; Office &amp;gt; Lighting &amp;gt; Table Lamps&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Factory and Office &amp;gt; Lighting &amp;gt; Wall Lamps &amp;amp; Sconces&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Home and Office &amp;gt; Lighting &amp;gt; Hanging &amp;amp; Pendant Lights&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to search and remove all the words after "Office". Usually I would use the Excel Function "Find and Replace" to find "Office*~ " and replace . However, I can't find a similar function in SAS advanced expression. Appreciate your advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimate Result as follows&lt;/P&gt;&lt;P&gt;&lt;EM&gt;House and Office&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Building and&amp;nbsp; Office&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Factory and Office&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Home and Office&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 10:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613500#M18428</guid>
      <dc:creator>SASnewbie2</dc:creator>
      <dc:date>2019-12-23T10:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove the text after a specific character/words</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613505#M18429</link>
      <description>&lt;P&gt;Your word "Office" is always followed by a "&amp;gt;". Can you use that as the delimiter? Then it would be a simple call of scan().&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 10:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613505#M18429</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-23T10:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove the text after a specific character/words</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613514#M18430</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200077"&gt;@SASnewbie2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use for example the PRXCHANGE function.&lt;/P&gt;
&lt;P&gt;In the below code, the function looks for the following pattern in variable var1:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF00FF"&gt;- Any character (.) zero, one or more time (*) at the beginning of the string (^)&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF00FF"&gt;- Followed by Office&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;- Followed by any character (.) zero, one or more time (*) at the end of the string ($)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first group of characters &lt;FONT color="#FF00FF"&gt;(in rose)&lt;/FONT&gt;&amp;nbsp;is enclosed in ( ) and can be retrieved by using $1&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	var2 = prxchange('s/(^.*Office).*$/$1/',1,var1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 11:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613514#M18430</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-23T11:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove the text after a specific character/words</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613662#M18465</link>
      <description>&lt;P&gt;Is that a simple function or formula I can use it in the advanced expression as shown below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my data was vary as show below so I can't use a delimiter and I try Scan() function, it doesn't show the result i wanted.Could be there's a mistake on my scan() formula&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Factory House and Office &amp;gt; Lighting &amp;gt; Floor Lamps&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;House Building and Office follows by Lighting then Table Lamps&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Factory and Office next Lighting last Wall Lamps &amp;amp; Sconces&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Home and Office then Lighting &amp;gt; Hanging &amp;amp; Pendant Lights&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimate Result as follows&lt;/P&gt;&lt;P&gt;&lt;EM&gt;House and Office&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Building and&amp;nbsp; Office&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Factory and Office&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Home and Office&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/35026iE1471ADCF9BB4BCF/image-size/large?v=1.0&amp;amp;px=-1" border="0" width="600" height="205" title="f.png" alt="f.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 02:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613662#M18465</guid>
      <dc:creator>SASnewbie2</dc:creator>
      <dc:date>2019-12-24T02:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove the text after a specific character/words</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613679#M18466</link>
      <description>&lt;P&gt;Using below data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input full_string $80.;
  datalines;
Factory House and Office &amp;gt; Lighting &amp;gt; Floor Lamps
House Building and Office follows by Lighting then Table Lamps
Factory and Office next Lighting last Wall Lamps &amp;amp; Sconces
Home and Office then Lighting &amp;gt; Hanging &amp;amp; Pendant Lights
Home and Work then Lighting &amp;gt; Hanging &amp;amp; Pendant Lights
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using the query builder you then can define a computed column &lt;EM&gt;want_string&lt;/EM&gt; using the following formula:&lt;/P&gt;
&lt;PRE&gt;substrn(t1.full_string, 1, ifn(findw(t1.full_string,'Office',' ','ip')&amp;gt;0, findw(t1.full_string,'Office',' ','ip')+5, 0) )&lt;/PRE&gt;
&lt;P&gt;Which then returns the following result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 494px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35027i68AB2590F6C675E3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The IFN() function gets used to return a value of Zero for strings with no word Office in it.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 05:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-remove-the-text-after-a-specific-character-words/m-p/613679#M18466</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-12-24T05:24:46Z</dc:date>
    </item>
  </channel>
</rss>

