<?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 Flagging pre-negation  and post-negation phrase in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291285#M60359</link>
    <description>&lt;P&gt;Hi tjhere,&lt;/P&gt;&lt;P&gt;For your kind information, I am trying to exclusion criteria for colon cases by flagging "Pre-negation phrase" and "Post negation" phrase.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, report having the statement "&lt;FONT color="#0000FF"&gt;NO EVIDENCE OF CARCINOMA&lt;/FONT&gt; IS SEEN IN THE &lt;FONT color="#0000FF"&gt;COLON&lt;/FONT&gt;" will be flagged as "NO_CARCINOMA=1" as "no evidence of" is present &amp;nbsp;either before or after the term colon within 10 words. As my reprts may contains multiple lines, I want to specify the word distance. Can somebody help me to write a code to flag it.&lt;/P&gt;&lt;P&gt;First I want to identify the term "&lt;FONT color="#0000FF"&gt;COLON&lt;/FONT&gt;" with the report and then within 10 words on either side of it, I want to identify presence of the negation term "&lt;FONT color="#0000FF"&gt;NO EVIDENCE OF CARCINOMA&lt;/FONT&gt; ". &amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample of data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;

  length text $200;
  id=1; text="NO EVIDENCE OF CARCINOMA IS SEEN IN THE COLON."; output;
  id=2; text="SPECIMEN OF COLON SHOWS NO EVIDENCE OF CARCINOMA BUT THERE IS SOME DYSPLASIC CHANGES"; output;
  id=3; text="ASCENDING COLON IS HAVING DEFINITIVE EVIDENCE OF CARCINOMA "; output;
  id=4; text="SIGMOID COLON IS HAVING MULTIPLE POLYP AS WELL AS FIRBROSIS. SPECIMEN OF LIVER IS ALSO HAVING NO EVIDENCE OF CARCINOMA "; output;
 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance for your kind guidance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Deepak&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Aug 2016 15:04:18 GMT</pubDate>
    <dc:creator>DeepakSwain</dc:creator>
    <dc:date>2016-08-12T15:04:18Z</dc:date>
    <item>
      <title>Flagging pre-negation  and post-negation phrase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291285#M60359</link>
      <description>&lt;P&gt;Hi tjhere,&lt;/P&gt;&lt;P&gt;For your kind information, I am trying to exclusion criteria for colon cases by flagging "Pre-negation phrase" and "Post negation" phrase.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, report having the statement "&lt;FONT color="#0000FF"&gt;NO EVIDENCE OF CARCINOMA&lt;/FONT&gt; IS SEEN IN THE &lt;FONT color="#0000FF"&gt;COLON&lt;/FONT&gt;" will be flagged as "NO_CARCINOMA=1" as "no evidence of" is present &amp;nbsp;either before or after the term colon within 10 words. As my reprts may contains multiple lines, I want to specify the word distance. Can somebody help me to write a code to flag it.&lt;/P&gt;&lt;P&gt;First I want to identify the term "&lt;FONT color="#0000FF"&gt;COLON&lt;/FONT&gt;" with the report and then within 10 words on either side of it, I want to identify presence of the negation term "&lt;FONT color="#0000FF"&gt;NO EVIDENCE OF CARCINOMA&lt;/FONT&gt; ". &amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample of data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;

  length text $200;
  id=1; text="NO EVIDENCE OF CARCINOMA IS SEEN IN THE COLON."; output;
  id=2; text="SPECIMEN OF COLON SHOWS NO EVIDENCE OF CARCINOMA BUT THERE IS SOME DYSPLASIC CHANGES"; output;
  id=3; text="ASCENDING COLON IS HAVING DEFINITIVE EVIDENCE OF CARCINOMA "; output;
  id=4; text="SIGMOID COLON IS HAVING MULTIPLE POLYP AS WELL AS FIRBROSIS. SPECIMEN OF LIVER IS ALSO HAVING NO EVIDENCE OF CARCINOMA "; output;
 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance for your kind guidance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Deepak&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 15:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291285#M60359</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2016-08-12T15:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging pre-negation  and post-negation phrase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291382#M60374</link>
      <description>&lt;P&gt;The approach I would take would be to divide the text into an array of words using the SCAN function, then look for the specific words you are looking for at the specific places, along the&amp;nbsp;lines of the code shown below. To explain the code, the two PROXIMITY variables limit how far apart the words COLON and CARCINOMA can be; the MIN and MAX operators ensure that array index values are within the range of the array; the CONTINUE statement stops looking at a specific location if the exact phrase NO EVIDENCE OF CARCINOMA is not found there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;data result (keep=id text NO_CARCINOMA);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp; set test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp; retain proximity_left 10 proximity_right 13;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp; array word{80} $ 16 _temporary_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp; do i = 1 to 80;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; word{i} = scan(text, i);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp; NO_CARCINOMA = 0;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp; do i = 1 to 80;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if word{i} = 'COLON' then &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j = 1 max (i - proximity_left) to (i + proximity_right) min 80;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if word{j} ne 'CARCINOMA' then continue;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if word{1 max (j - 3) min 80} ne 'NO' or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; word{1 max (j - 2) min 80} ne 'EVIDENCE' or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; word{1 max (j - 1) min 80} ne 'OF' then continue;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NO_CARCINOMA = 1;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leave;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff" face="andale mono,times"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 18:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291382#M60374</guid>
      <dc:creator>RickAster</dc:creator>
      <dc:date>2016-08-12T18:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging pre-negation  and post-negation phrase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291542#M60404</link>
      <description>&lt;P&gt;Better do it with pattern matching :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;

  length id 8 text $200;
  id=1; text="NO EVIDENCE OF CARCINOMA IS SEEN IN THE COLON."; output;
  id=2; text="SPECIMEN OF COLON SHOWS NO EVIDENCE OF CARCINOMA BUT THERE IS SOME DYSPLASIC CHANGES"; output;
  id=3; text="ASCENDING COLON IS HAVING DEFINITIVE EVIDENCE OF CARCINOMA "; output;
  id=4; text="SIGMOID COLON IS HAVING MULTIPLE POLYP AS WELL AS FIRBROSIS. SPECIMEN OF LIVER IS ALSO HAVING NO EVIDENCE OF CARCINOMA "; output;
 
run;

data check;
if not prx1 then 
    prx1 + prxParse("/COLON(\W+\w+){1,10}\W+NO EVIDENCE OF CARCINOMA|NO EVIDENCE OF CARCINOMA(\W+\w+){1,10}\W+COLON/i");
set test;
NO_CARCINOMA = prxMatch(prx1, text) &amp;gt; 0;
drop prx1;
run;

proc sql; select * from check; quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Aug 2016 20:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291542#M60404</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-08-13T20:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging pre-negation  and post-negation phrase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291676#M60422</link>
      <description>&lt;P&gt;Hi PGStats,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Accept my apology for late reply. The advice given by you is accurately anaswering my needs.The sas code provided is very simple and easy to apply in different scenario in the future too.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Deepak&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2016 13:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291676#M60422</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2016-08-15T13:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging pre-negation  and post-negation phrase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291678#M60423</link>
      <description>&lt;P&gt;Hi RickAster,&lt;/P&gt;&lt;P&gt;Kindly accept my apology for the delayed reply. The solutuion provided by you is answering my issue accurately.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although for the current issue , I am going with pattern matching, but I will keep&amp;nbsp;your sas coding using array for the future to deal with more&amp;nbsp;complex needs because your code is flexible enough to&amp;nbsp;search multiple words having&amp;nbsp;variable word distance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once again thank you for your kind guidance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Deepak&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2016 13:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-pre-negation-and-post-negation-phrase/m-p/291678#M60423</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2016-08-15T13:37:53Z</dc:date>
    </item>
  </channel>
</rss>

