<?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 entire email address and quotes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880376#M347855</link>
    <description>&lt;P&gt;An alternative with regexp:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list=('donald.duck@cartoon.com' 'becky.green@grass.com' 'mark.tomas@lbschool.net');
%let str='donald.duck@cartoon.com';


data _null_;
  length stringToDrop $ 256;
  stringToDrop=symget('str');

  /* mask special characters to get stringToDrop="\'donald\.duck\@cartoon\.com\'" */
  do s="'",'"',"@",'.';
    s2='\'!!s;
    stringToDrop=TRANWRD(stringToDrop, s, s2);
  end;
  put stringToDrop=;
  

  length example $ 32767;
  example=symget('list');
  put "before:" @10 example;
 
  example=PRXCHANGE('s/' !! strip(stringToDrop)!! '//', -1, example);
  put "after:" @10 example;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jun 2023 11:11:57 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2023-06-13T11:11:57Z</dc:date>
    <item>
      <title>Remove entire email address and quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880330#M347831</link>
      <description>&lt;P&gt;I have an email string with a list of email addresses. each email address is surrounded by single quotes. i want to write a program that will remove or add an email address with the quotes around it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;'donald.duck@cartoon.com'&lt;/P&gt;&lt;P&gt;I can search the string for the email to remove using compress but I cannot remove the single quotes around it because other email's have the quotes.&lt;/P&gt;&lt;P&gt;Any suggestions on how to get rid of the quotes once the email is gone or both at once?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;before code&amp;nbsp;&lt;/P&gt;&lt;P&gt;example string: ('donald.duck@cartoon.com' 'becky.green@grass.com' 'mark.tomas@lbschool.net')&lt;/P&gt;&lt;P&gt;after process&amp;nbsp;&lt;/P&gt;&lt;P&gt;example string: (&lt;FONT color="#FF0000"&gt;''&lt;/FONT&gt; 'becky.green@grass.com' 'mark.tomas@lbschool.net')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 01:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880330#M347831</guid>
      <dc:creator>grnize</dc:creator>
      <dc:date>2023-06-13T01:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Remove entire email address and quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880339#M347835</link>
      <description>&lt;P&gt;I cannot tell from your description what your dataset looks like. Or for that matter if you even have a dataset.&lt;/P&gt;
&lt;P&gt;Post some example datasets.&amp;nbsp; Input and Output.&amp;nbsp; Please post them as code that can be run to re-create them.&amp;nbsp; It does not have to be real data or very much data.&amp;nbsp; Just something that makes it clear what you are trying to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I cannot figure out how the COMPRESS() could be used to do anything that you asked about.&amp;nbsp; If you have tried something the show that also.&amp;nbsp; If you get error messages show the SAS log for the step with errors. If it just doesn't do what you want explain what is wrong with the output.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 03:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880339#M347835</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-13T03:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Remove entire email address and quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880372#M347853</link>
      <description>&lt;P&gt;Try like this, I assumed the list of emails is provides as a macro variable,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list=('donald.duck@cartoon.com' 'becky.green@grass.com' 'mark.tomas@lbschool.net');



data _null_;
  stringToDrop='donald.duck@cartoon.com';

  length example ex $ 32767;
  example=symget('list');
  put "before:" @10 example;
  do i=1 to countw(example, "( )");
    part=dequote(scan(example, i, "( )"));
    if part ne stringToDrop then
      ex=catx(" ", ex, quote(strip(part), "'") );
  end;

  example="(" !! strip(ex) !! ")";
  put "after:" @10 example;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 10:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880372#M347853</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-06-13T10:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Remove entire email address and quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880376#M347855</link>
      <description>&lt;P&gt;An alternative with regexp:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list=('donald.duck@cartoon.com' 'becky.green@grass.com' 'mark.tomas@lbschool.net');
%let str='donald.duck@cartoon.com';


data _null_;
  length stringToDrop $ 256;
  stringToDrop=symget('str');

  /* mask special characters to get stringToDrop="\'donald\.duck\@cartoon\.com\'" */
  do s="'",'"',"@",'.';
    s2='\'!!s;
    stringToDrop=TRANWRD(stringToDrop, s, s2);
  end;
  put stringToDrop=;
  

  length example $ 32767;
  example=symget('list');
  put "before:" @10 example;
 
  example=PRXCHANGE('s/' !! strip(stringToDrop)!! '//', -1, example);
  put "after:" @10 example;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 11:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880376#M347855</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-06-13T11:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Remove entire email address and quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880394#M347862</link>
      <description>&lt;P&gt;You can use TRANSTRN(), e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    data want ;
2      string="('donald.duck@cartoon.com' 'becky.green@grass.com' 'mark.tomas@lbschool.net')" ;
3      string2=transtrn(string,"'donald.duck@cartoon.com'",trimn("")) ;
4      put string2= ;
5    run ;

string2=( 'becky.green@grass.com' 'mark.tomas@lbschool.net')
NOTE: The data set WORK.WANT has 1 observations and 2 variables.
&lt;/PRE&gt;
&lt;P&gt;This doesn't get rid of the extra blank left behind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 12:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880394#M347862</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-06-13T12:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Remove entire email address and quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880397#M347865</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
have="('donald.duck@cartoon.com' 'becky.green@grass.com' 'mark.tomas@lbschool.net')";
want=prxchange("s/'[^']+'//",1,have);

put have= / want=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;73   data _null_;
74   have="('donald.duck@cartoon.com' 'becky.green@grass.com' 'mark.tomas@lbschool.net')";
75   want=prxchange("s/'[^']+'//",1,have);
76
77   put have= / want=;
78   run;

have=('donald.duck@cartoon.com' 'becky.green@grass.com' 'mark.tomas@lbschool.net')
want=( 'becky.green@grass.com' 'mark.tomas@lbschool.net')
NOTE: “DATA 语句”所用时间（总处理时间）:
      实际时间          0.03 秒
      CPU 时间          0.00 秒

&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jun 2023 12:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880397#M347865</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-06-13T12:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Remove entire email address and quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880566#M347918</link>
      <description>&lt;P&gt;Bart solution worked best for me because it removed the space too. thank you so much&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 01:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-entire-email-address-and-quotes/m-p/880566#M347918</guid>
      <dc:creator>grnize</dc:creator>
      <dc:date>2023-06-14T01:19:51Z</dc:date>
    </item>
  </channel>
</rss>

