<?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 do I find &amp;amp; replace a large list of names from a large string (Redaction)? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517540#M3345</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/249187"&gt;@Lorielus&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apologies, I think I'm maybe being misleading, I'm not looking for an overall solution, just the syntax for how to reference&amp;nbsp;LIB.NAMELIST.NAME as the target for the TRANSWRD statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In Proc SQL you can use an alias: lib.namelist as Z to create the alias and then use as z.name.&amp;nbsp; Should be basic stuff to a moderately experienced SQL user though perhaps you were unaware of the existence of Proc SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS has a less common bit of coding referred to as SCL and that is the only place (I am familiar with) that SAS will accept a construct like LIB.NAMELIST.NAME&amp;nbsp;.&amp;nbsp; Namelist would be expected to be a Catalog since there is something following the second level name and then Name would be expected to be an entry in the catalog&lt;/P&gt;</description>
    <pubDate>Fri, 30 Nov 2018 16:12:04 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-11-30T16:12:04Z</dc:date>
    <item>
      <title>How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517461#M3334</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Context here is I have a rudimentary SAS skillset at best (normally an SQL data monkey), and am looking for some syntax advice on how to reference a specific column from a data set to use as a list of strings to find and replace within a large free text string with a "[NAME REDACTED] placeholder.&amp;nbsp; The overall goal here is to replace a huge list of names (~400k) from free text description fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The name list (referring to this as &lt;STRONG&gt;LIB.NAMELIST)&lt;/STRONG&gt; appears along the lines of:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ID&amp;nbsp; &amp;nbsp; Name&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; Jim&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; Dave&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; Susan&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; Fiona&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My plan was to do this with a simple WHILE look, something along the lines of the below (italics is where I don't know how to reference this dataset &amp;amp; column in the loop):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data=have;&lt;BR /&gt;set=want;&lt;BR /&gt;nstart=1;&lt;BR /&gt;nend=400000;&lt;BR /&gt;do while(nstart&amp;lt;=nfinish);&lt;BR /&gt;TRANWRD(DescriptionField,&lt;EM&gt;(SELECT NAME FROM LIB.NAMELIST.Name WHERE ID = nstart)&lt;/EM&gt;,"[NAME REDACTED]";&lt;BR /&gt;n+1&lt;BR /&gt;;&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 13:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517461#M3334</guid>
      <dc:creator>Lorielus</dc:creator>
      <dc:date>2018-11-30T13:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517467#M3336</link>
      <description>&lt;P&gt;Could you please provide test data for both datasets in the form of a datastep:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise I have nothing to work with.&amp;nbsp; I can think of several ways of doing it - format, proc sql (with which you can use your subclause shown), datastep merge with point statment, proc sql/datastep merge, hash table lookup.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 13:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517467#M3336</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-30T13:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517472#M3337</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies, I think I'm maybe being misleading, I'm not looking for an overall solution, just the syntax for how to reference&amp;nbsp;LIB.NAMELIST.NAME as the target for the TRANSWRD statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 13:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517472#M3337</guid>
      <dc:creator>Lorielus</dc:creator>
      <dc:date>2018-11-30T13:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517491#M3339</link>
      <description>&lt;P&gt;As someone with modest SQL skills (as you will see below), I would think this is possible by calling upon your SQL data monkey skills.&amp;nbsp; SAS contains PROC SQL which ought to be able to do something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as select * from have,&lt;/P&gt;
&lt;P&gt;case (when name in (select name from lib.namelist) then "NAME REDACTED")&lt;/P&gt;
&lt;P&gt;else name) as newname;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps I oversimplified the problem?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 14:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517491#M3339</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-11-30T14:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517494#M3340</link>
      <description>&lt;P&gt;You can't.&amp;nbsp; Datastep do not work that way.&amp;nbsp; You can do as you show using proc sql or&amp;nbsp;use one of the other methods I presented.&amp;nbsp; It depends on what you are trying to do, and what your data looks like, it sounds like you are trying to remove any words from a text string in a list of given words.&amp;nbsp; If so, then something like (and I will type in the test data for you):&lt;/P&gt;
&lt;PRE&gt;data have;
  length str $200;
  str="A long string of wods with some to be removed";
run;

data list;
  length wrd $200;
  wrd="string";output;
  wrd="removed";output;
run;

data _null_;
  set list end=last;
  if _n_=1 then call execute('data want; set have;');
  call execute(cats('str=tranwrd(str,"',wrd,'","");'));
  if last then call execute('run;');
run;
  &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 14:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517494#M3340</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-30T14:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517540#M3345</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/249187"&gt;@Lorielus&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apologies, I think I'm maybe being misleading, I'm not looking for an overall solution, just the syntax for how to reference&amp;nbsp;LIB.NAMELIST.NAME as the target for the TRANSWRD statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In Proc SQL you can use an alias: lib.namelist as Z to create the alias and then use as z.name.&amp;nbsp; Should be basic stuff to a moderately experienced SQL user though perhaps you were unaware of the existence of Proc SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS has a less common bit of coding referred to as SCL and that is the only place (I am familiar with) that SAS will accept a construct like LIB.NAMELIST.NAME&amp;nbsp;.&amp;nbsp; Namelist would be expected to be a Catalog since there is something following the second level name and then Name would be expected to be an entry in the catalog&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 16:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/517540#M3345</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-30T16:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518325#M3520</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your effort on this, I really appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are right in the intent as I outlined in the original post.&amp;nbsp; However, again the issue is not with the replacement of words within the string, but how do I reference a list of words from a column in a data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, you have defined the list of words with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data list;
  length wrd $200;
  wrd="string";output;
  wrd="removed";output;
run;&lt;/PRE&gt;&lt;P&gt;But I cannot type out 412,000 variations of wrd="string";output; to create the list to loop through - so the question as before remains, how do I define "list" in the above as&amp;nbsp;the column "Name" from LIB.NAMELIST?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 08:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518325#M3520</guid>
      <dc:creator>Lorielus</dc:creator>
      <dc:date>2018-12-04T08:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518327#M3521</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;But I cannot type out 412,000 variations of wrd="string"" - you do not need to.&amp;nbsp; What I presented there was an&amp;nbsp;&lt;STRONG&gt;example&lt;/STRONG&gt;, as you have not provided anything for us to work with.&amp;nbsp; I will assume that "LIB.NAMELIST" is a dataset which already contains this information, so you use that rather than my example I gave.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 08:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518327#M3521</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-04T08:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518328#M3522</link>
      <description>&lt;P&gt;Thank you - so how do I reference LIB.NAMELIST.Name in that code?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 08:59:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518328#M3522</guid>
      <dc:creator>Lorielus</dc:creator>
      <dc:date>2018-12-04T08:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518333#M3523</link>
      <description>&lt;P&gt;If its a dataset, in a library called lib, and is called namelist, and contains a variable name (all of which you still have not told us, nor shown any examples of):&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set lib.namelist end=last;
  if _n_=1 then call execute('data want; set have;');
  call execute(cats('str=tranwrd(str,"',name,'","");'));
  if last then call execute('run;');
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Dec 2018 09:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518333#M3523</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-04T09:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518339#M3525</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time, I really appreciate it, I'll seek an alternative solution.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 10:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518339#M3525</guid>
      <dc:creator>Lorielus</dc:creator>
      <dc:date>2018-12-04T10:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518340#M3526</link>
      <description>&lt;P&gt;Why?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 10:06:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518340#M3526</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-04T10:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find &amp; replace a large list of names from a large string (Redaction)?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518745#M3614</link>
      <description>&lt;P&gt;The eventual solution used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data name_list;
  input ID  Name $;
  datalines;
1     Jim
2     Steve
3     Susan
4     Karen
;
run;

data have;
  input text $100.;
  infile datalines truncover;
  datalines;
Jim AAA
Steve Susan BBB
Susanne CCC
;
run;

proc sql noprint;
  select count(*) into :n from name_list ;
quit;

data want;
  set have;
  array names[&amp;amp;n] $30 _temporary_;
  if _n_ = 1 then do i = 1 to &amp;amp;n;
    set name_list(keep = name);
    names[i] = name;
  end;
  do i = 1 to &amp;amp;n;
    text = tranwrd(text,strip(names[i]),'[NAME REDACTED]');
  end;
 keep text;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Dec 2018 11:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-find-amp-replace-a-large-list-of-names-from-a-large/m-p/518745#M3614</guid>
      <dc:creator>Lorielus</dc:creator>
      <dc:date>2018-12-05T11:51:11Z</dc:date>
    </item>
  </channel>
</rss>

