<?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: Removing character strings in a variable using advanced filter in Querybuilder in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691277#M37290</link>
    <description>&lt;P&gt;Perfect! Good job.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Tue, 13 Oct 2020 14:24:17 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2020-10-13T14:24:17Z</dc:date>
    <item>
      <title>Removing character strings in a variable using advanced filter in Querybuilder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691114#M37277</link>
      <description>&lt;P&gt;Hi, I'm working on a problem that wants me to create an advanced filter for a 'Phone_number" variable, that removes the extension at the beginning of the phone numbers, making them 7 digit numbers. The extensions are&amp;nbsp;+61(2)',&amp;nbsp;'+61(3)', and '+61(5)'&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I've been trying :&lt;STRONG&gt;&amp;nbsp;COMPRESS(t1.Phone_Number, "+61(2)", "+61(3)", "+61(5)")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone please tell me what I'm doing wrong and provide the correct FUNCTION to use in this scenario.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 01:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691114#M37277</guid>
      <dc:creator>BrockJarvie</dc:creator>
      <dc:date>2020-10-13T01:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Removing character strings in a variable using advanced filter in Querybuilder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691135#M37281</link>
      <description>&lt;P&gt;COMPRESS treats the second parameter as a list of characters to get rid of.&amp;nbsp; For example, "+61(2)" will get rid of all 6's, 1's, and 2's, no matter where they are.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TRANSTRN is probably the better function for this purpose.&amp;nbsp; TRANSTRN can translate a string in to a null (i.e. remove without replacing it with anything).&amp;nbsp; TRANWRD would probably also work but leaves a space in place afterwards which would have to be removed by a LEFT or a STRIP or a similar function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If they're all of the same length, it would be easy to use SUBSTR as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 03:33:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691135#M37281</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T03:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Removing character strings in a variable using advanced filter in Querybuilder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691136#M37282</link>
      <description>Thank you!</description>
      <pubDate>Tue, 13 Oct 2020 03:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691136#M37282</guid>
      <dc:creator>BrockJarvie</dc:creator>
      <dc:date>2020-10-13T03:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Removing character strings in a variable using advanced filter in Querybuilder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691137#M37283</link>
      <description>&lt;P&gt;You're welcome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are a couple of examples if they're helpful.&amp;nbsp; The below code produces two "cleaned" phone numbers (no prefix).&amp;nbsp; One was produced via the TRANSTRN, the other by SUBSTR.&amp;nbsp; Notice that the SUBSTR is a lot easier to code if all your prefixes are of equal length.&amp;nbsp; If they're not all of equal length, then you'd probably have to find the closing parenthesis and add 2 in order to get the second parameter for the SUBSTR.&amp;nbsp; &amp;nbsp;Either one will work as will TRANWRD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below the code are the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	Cleaned_Phone_Numbers;
	SET	Raw_Phone_NUmbers;

	Phone_No1	=	TRANSTRN(Phone_No,  '+61(2) ', STRIP(''));
	Phone_No1	=	TRANSTRN(Phone_No1, '+61(3) ', STRIP(''));
	Phone_No1	=	TRANSTRN(Phone_No1, '+61(5) ', STRIP(''));
	Phone_No2	=	SUBSTR(Phone_No, 7);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Results, showing original, TRANSTRN results, and SUBSTR results.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1602560880969.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50588i26C113B5EDAD7AAD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jimbarbour_0-1602560880969.png" alt="jimbarbour_0-1602560880969.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 03:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691137#M37283</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T03:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Removing character strings in a variable using advanced filter in Querybuilder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691144#M37284</link>
      <description>&lt;P&gt;So this should all be done as a computed column right? an advanced filter wouldn't be able to change the current 'Phone_Number' column to the 7-digit number.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 06:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691144#M37284</guid>
      <dc:creator>BrockJarvie</dc:creator>
      <dc:date>2020-10-13T06:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Removing character strings in a variable using advanced filter in Querybuilder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691149#M37285</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/349329"&gt;@BrockJarvie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So this should all be done as a computed column right? an advanced filter wouldn't be able to change the current 'Phone_Number' column to the 7-digit number.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, I believe that's the right terminology for Query Builder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should translate to SQL something along the lines of:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Select SUBSTR(Phone_No, 7) AS Phone_No&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that doesn't work for some reason, please post the log, and we can take a look at it.&amp;nbsp; When you post the log, please use the Insert Code button on the reply window.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1602572924717.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50590i847C1E723D3897A9/image-size/large?v=v2&amp;amp;px=999" role="button" title="jimbarbour_0-1602572924717.png" alt="jimbarbour_0-1602572924717.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 07:08:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691149#M37285</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T07:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Removing character strings in a variable using advanced filter in Querybuilder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691274#M37289</link>
      <description>&lt;P&gt;Thank you for your help!&amp;nbsp;I wa&lt;SPAN style="font-family: inherit;"&gt;s able to create the revised Phone_Number column with the SUBSTRN function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled-1 (2).png" style="width: 179px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50610iDC0E8692A451ED74/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled-1 (2).png" alt="Untitled-1 (2).png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 14:15:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691274#M37289</guid>
      <dc:creator>BrockJarvie</dc:creator>
      <dc:date>2020-10-13T14:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Removing character strings in a variable using advanced filter in Querybuilder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691277#M37290</link>
      <description>&lt;P&gt;Perfect! Good job.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 14:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Removing-character-strings-in-a-variable-using-advanced-filter/m-p/691277#M37290</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T14:24:17Z</dc:date>
    </item>
  </channel>
</rss>

