<?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 Use proc textmine to remove terms in my dataset where role=nlpPerson? in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Use-proc-textmine-to-remove-terms-in-my-dataset-where-role/m-p/837532#M10323</link>
    <description>&lt;P&gt;I used proc textmine to identify terms (person's names) in my dataset where Role=nlpPerson.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to replace all the names in my dataset with "Person_Name" ?&lt;/P&gt;
&lt;P&gt;For example, the terms John Doe, John Smith, George Adams, etc were identified as having the role nlpPerson, now I want to replace all those terms in my dataset of role=nlpPerson with "Person_Name".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the solution I'm using at the moment, where may ORDERS_TEXT table contains a column for each ORDER_ID and a column of TEXT for each order:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data outterms;
set mycas.outterms;
where Role='nlpPerson';
rownum=_n_;
run;

data outterms;
keep rownum Term;
retain rownum Term;
set outterms;
run;

proc sql noprint;
select count(*) into :n from outterms ;
quit;

data want;
length text $3500;
set MYCAS.ORDERS_TEXT;
array names[&amp;amp;n] $3500 _temporary_;
if _n_ = 1 then do i = 1 to &amp;amp;n;
set outterms(keep = Term);
names[i] = Term;
end;
do i = 1 to &amp;amp;n;
TEXT = tranwrd(lowcase(TEXT),strip(names[i]),'[NAME REDACTED]');
end;
keep ORDER_ID TEXT;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 08 Oct 2022 20:53:10 GMT</pubDate>
    <dc:creator>PharmlyDoc</dc:creator>
    <dc:date>2022-10-08T20:53:10Z</dc:date>
    <item>
      <title>Use proc textmine to remove terms in my dataset where role=nlpPerson?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Use-proc-textmine-to-remove-terms-in-my-dataset-where-role/m-p/837532#M10323</link>
      <description>&lt;P&gt;I used proc textmine to identify terms (person's names) in my dataset where Role=nlpPerson.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to replace all the names in my dataset with "Person_Name" ?&lt;/P&gt;
&lt;P&gt;For example, the terms John Doe, John Smith, George Adams, etc were identified as having the role nlpPerson, now I want to replace all those terms in my dataset of role=nlpPerson with "Person_Name".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the solution I'm using at the moment, where may ORDERS_TEXT table contains a column for each ORDER_ID and a column of TEXT for each order:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data outterms;
set mycas.outterms;
where Role='nlpPerson';
rownum=_n_;
run;

data outterms;
keep rownum Term;
retain rownum Term;
set outterms;
run;

proc sql noprint;
select count(*) into :n from outterms ;
quit;

data want;
length text $3500;
set MYCAS.ORDERS_TEXT;
array names[&amp;amp;n] $3500 _temporary_;
if _n_ = 1 then do i = 1 to &amp;amp;n;
set outterms(keep = Term);
names[i] = Term;
end;
do i = 1 to &amp;amp;n;
TEXT = tranwrd(lowcase(TEXT),strip(names[i]),'[NAME REDACTED]');
end;
keep ORDER_ID TEXT;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Oct 2022 20:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Use-proc-textmine-to-remove-terms-in-my-dataset-where-role/m-p/837532#M10323</guid>
      <dc:creator>PharmlyDoc</dc:creator>
      <dc:date>2022-10-08T20:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Use proc textmine to remove terms in my dataset where role=nlpPerson?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Use-proc-textmine-to-remove-terms-in-my-dataset-where-role/m-p/843858#M10374</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366713"&gt;@PharmlyDoc&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Yes, your solution will work to redact person names from text. Three possible options suggested by my colleagues, when I asked them about your use case, were:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) You can use the output of applyConcepts with predefined = true instead of proc textMine, if you want to leverage the identification of the text offsets (position of the pieces of text you are targeting). This will help avoid possible conflicts, if a name might also be similar to a non-name in your data - for example Martin Luther King vs. Martin Luther King Highway. This approach will pinpoint the names in the text accurately and redact only those items vs. getting confused with things like addresses.&lt;/P&gt;
&lt;P&gt;2) If you find your code is not as efficient as you would like, you could try using the terms (and offsets) as a hash table within a data step.&lt;/P&gt;
&lt;P&gt;3) If you want to add lowcase to your text line, it will ignore casing on the comparison:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;text = tranwrd(lowcase(text),&lt;STRONG&gt;lowcase&lt;/STRONG&gt;(strip(names[i])),'[NAME REDACTED]');&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;4) This is a great example of text redaction, and it could be made into a macro to redact other types of PII information such as social security numbers as '###-##-####'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let us know how it goes!&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 21:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Use-proc-textmine-to-remove-terms-in-my-dataset-where-role/m-p/843858#M10374</guid>
      <dc:creator>TeresaJade</dc:creator>
      <dc:date>2022-11-11T21:07:59Z</dc:date>
    </item>
  </channel>
</rss>

