<?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: search words in table --- index in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1844#M818</link>
    <description>Bonjour Marion.&lt;BR /&gt;
&lt;BR /&gt;
I don't know if your data looks like this example, but maybe trying something with the INDEXW function and merging the two datasets with the SQL procedure can help.&lt;BR /&gt;
&lt;BR /&gt;
DATA work.probable ;&lt;BR /&gt;
	INPUT word :$20. ;&lt;BR /&gt;
CARDS ;&lt;BR /&gt;
pain&lt;BR /&gt;
headache&lt;BR /&gt;
sore&lt;BR /&gt;
;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
DATA work.agtxti_copy ;&lt;BR /&gt;
	INFILE CARDS DLM = "/" ;&lt;BR /&gt;
	INPUT txtaga :$200. ;&lt;BR /&gt;
CARDS ;&lt;BR /&gt;
No problems at all.&lt;BR /&gt;
Feeling of sore throat.&lt;BR /&gt;
Feeling some pain in the neck.&lt;BR /&gt;
Sore throat.&lt;BR /&gt;
;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC SQL ;&lt;BR /&gt;
	SELECT txtaga AS sentence,&lt;BR /&gt;
		   MAX((INDEXW(UPCASE(a.txtaga), UPCASE(b.word))&amp;gt;0)) AS word_is_in_sentence&lt;BR /&gt;
	FROM work.agtxti_copy AS a,&lt;BR /&gt;
		 work.probable AS b&lt;BR /&gt;
	GROUP BY sentence&lt;BR /&gt;
	;&lt;BR /&gt;
QUIT ;</description>
    <pubDate>Thu, 23 Nov 2006 14:38:13 GMT</pubDate>
    <dc:creator>Olivier</dc:creator>
    <dc:date>2006-11-23T14:38:13Z</dc:date>
    <item>
      <title>search words in table --- index</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1843#M817</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
My goal is to initialize a field to :&lt;BR /&gt;
0 if the record in the agtxti_copy.sas7bdat table does not contain the words of the probable.sas7bdat table.&lt;BR /&gt;
1 if the record contains the word present in the probable.sas7bdat table.&lt;BR /&gt;
&lt;BR /&gt;
The problem is that the field is always equals to 0 even if the field in the agtxti_copy.sas7bdat table contains the word of the probable.sas7bdat table...&lt;BR /&gt;
&lt;BR /&gt;
Here is my source code :&lt;BR /&gt;
&lt;BR /&gt;
----------------------------&lt;BR /&gt;
%MACRO L(M=);&lt;BR /&gt;
	(index(txtaga||txtagb,"&amp;amp;M")+index(txtagc||txtagd,"&amp;amp;M")+index(txtage||txtagf,"&amp;amp;M"))&lt;BR /&gt;
%MEND L;&lt;BR /&gt;
&lt;BR /&gt;
data result.agtxti_critpi /DEBUG;&lt;BR /&gt;
	set agtxti_copy;&lt;BR /&gt;
	dsid=open("siqf.probable");&lt;BR /&gt;
	nobs=attrn(dsid,"nobs");&lt;BR /&gt;
	do i=1 to nobs;&lt;BR /&gt;
		rc = fetchobs(dsid,1);&lt;BR /&gt;
		mot1=getvarc(dsid,varnum(dsid,'MOT1'));&lt;BR /&gt;
		ARR_M1 =%L(M=eval(mot1)); /* this does not work because ARR_M1 = 0*/&lt;BR /&gt;
		ARR_M2 =%L(M=IMMOBILIS); /* this works because ARR_M2 &amp;gt; 0*/&lt;BR /&gt;
		test1=index(txtagc,mot1); /* this does not work because test1 = 0*/&lt;BR /&gt;
		test2=index(txtagc,'IMMOBILIS'); /* this works because test2 &amp;gt; 0*/&lt;BR /&gt;
		put test;&lt;BR /&gt;
	end;&lt;BR /&gt;
	dsid=close(dsid);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
-----------------------------&lt;BR /&gt;
Can somebody help me ?&lt;BR /&gt;
&lt;BR /&gt;
Thank you for your answer.&lt;BR /&gt;
&lt;BR /&gt;
Marion</description>
      <pubDate>Thu, 23 Nov 2006 09:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1843#M817</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-11-23T09:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: search words in table --- index</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1844#M818</link>
      <description>Bonjour Marion.&lt;BR /&gt;
&lt;BR /&gt;
I don't know if your data looks like this example, but maybe trying something with the INDEXW function and merging the two datasets with the SQL procedure can help.&lt;BR /&gt;
&lt;BR /&gt;
DATA work.probable ;&lt;BR /&gt;
	INPUT word :$20. ;&lt;BR /&gt;
CARDS ;&lt;BR /&gt;
pain&lt;BR /&gt;
headache&lt;BR /&gt;
sore&lt;BR /&gt;
;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
DATA work.agtxti_copy ;&lt;BR /&gt;
	INFILE CARDS DLM = "/" ;&lt;BR /&gt;
	INPUT txtaga :$200. ;&lt;BR /&gt;
CARDS ;&lt;BR /&gt;
No problems at all.&lt;BR /&gt;
Feeling of sore throat.&lt;BR /&gt;
Feeling some pain in the neck.&lt;BR /&gt;
Sore throat.&lt;BR /&gt;
;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC SQL ;&lt;BR /&gt;
	SELECT txtaga AS sentence,&lt;BR /&gt;
		   MAX((INDEXW(UPCASE(a.txtaga), UPCASE(b.word))&amp;gt;0)) AS word_is_in_sentence&lt;BR /&gt;
	FROM work.agtxti_copy AS a,&lt;BR /&gt;
		 work.probable AS b&lt;BR /&gt;
	GROUP BY sentence&lt;BR /&gt;
	;&lt;BR /&gt;
QUIT ;</description>
      <pubDate>Thu, 23 Nov 2006 14:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1844#M818</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2006-11-23T14:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: search words in table --- index</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1845#M819</link>
      <description>Thank you for your answer but I have again a problem...&lt;BR /&gt;
&lt;BR /&gt;
In fact, we can have parts of words to search and probably not a entire word...&lt;BR /&gt;
&lt;BR /&gt;
So I keep your example and I used the index function instead of the indexw function. But it doesn't work. Here is the result I obtained :&lt;BR /&gt;
sentence : ENTRAINE PANNE IMMOBILISANTE&lt;BR /&gt;
part of word : IMMOBILIS&lt;BR /&gt;
index : 0&lt;BR /&gt;
&lt;BR /&gt;
and here is my source code (the same as yours) :&lt;BR /&gt;
PROC SQL /DEBUG;&lt;BR /&gt;
SELECT a.txtagc AS sentence,&lt;BR /&gt;
	   b.mot1 AS word,&lt;BR /&gt;
	   INDEX(a.txtagc,b.mot1) AS index,&lt;BR /&gt;
	   MAX((INDEX(UPCASE(a.txtagc), UPCASE(b.mot1))&amp;gt;0)) AS word_is_in_sentence&lt;BR /&gt;
FROM work.agtxti_copypeu AS a,&lt;BR /&gt;
	 siqf.probablepeu AS b&lt;BR /&gt;
GROUP BY sentence&lt;BR /&gt;
;&lt;BR /&gt;
QUIT ;&lt;BR /&gt;
&lt;BR /&gt;
is the proc sql more powerful than the code I mentionned (open the table, ...) ?&lt;BR /&gt;
&lt;BR /&gt;
Thank you for your answer.</description>
      <pubDate>Fri, 24 Nov 2006 08:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1845#M819</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-11-24T08:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: search words in table --- index</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1846#M820</link>
      <description>Just one more thing. My code in my first post could not works because I forgot something :&lt;BR /&gt;
&lt;BR /&gt;
%MACRO L(M=);&lt;BR /&gt;
	(index(txtaga||txtagb,"&amp;amp;M")+index(txtagc||txtagd,"&amp;amp;M")+index(txtage||txtagf,"&amp;amp;M"))&lt;BR /&gt;
%MEND L;&lt;BR /&gt;
data result.agtxti_critpi ;&lt;BR /&gt;
	set agtxti_temp;&lt;BR /&gt;
	dsid=open("siqf.probable");&lt;BR /&gt;
	nobs=attrn(dsid,"nobs");&lt;BR /&gt;
	ARR_M_TEMP=0;&lt;BR /&gt;
	ARR_M=0;&lt;BR /&gt;
	do i=1 to nobs;&lt;BR /&gt;
		rc = fetchobs(dsid,i);&lt;BR /&gt;
		mot1=getvarc(dsid,varnum(dsid,'MOT1'));&lt;BR /&gt;
                /* Rajout */&lt;BR /&gt;
		%let mot1=&amp;amp;mot1;&lt;BR /&gt;
		ARR_M_TEMP = ARR_M_TEMP + %L(M=&amp;amp;mot1);&lt;BR /&gt;
test=index(txtaga||txtagb,"&amp;amp;mot1")+index(txtagc||txtagd,"&amp;amp;mot1")+index(txtage||txtagf,"&amp;amp;mot1");&lt;BR /&gt;
	end;&lt;BR /&gt;
	if ARR_M_TEMP&amp;gt;0 then do;&lt;BR /&gt;
		ARR_M=1;&lt;BR /&gt;
	else do;&lt;BR /&gt;
		ARR_M=0;&lt;BR /&gt;
	end;&lt;BR /&gt;
	dsid=close(dsid);&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 24 Nov 2006 08:56:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1846#M820</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-11-24T08:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: search words in table --- index</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1847#M821</link>
      <description>Well Marion, I think that the main problem your program encounters is mixing macro-language and SAS language : both can work together, but not at the same time.&lt;BR /&gt;
When you submit a program including both macro and normal statements, the macro facility is compiled and executed first ; it should return text that is considered as SAS code. And then the transform program is executed.&lt;BR /&gt;
For example, when you submit :&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_ ;&lt;BR /&gt;
   SET sashelp.class (OBS = 1) ;&lt;BR /&gt;
   %LET MVage = age ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC PRINT DATA = sashelp.class (WHERE = (age &amp;gt; &amp;amp;MVage)) ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
&lt;BR /&gt;
The first executed statement is &lt;BR /&gt;
%LET MVage = age ;&lt;BR /&gt;
&lt;BR /&gt;
it does not mean that the VALUE of the SAS variable AGE is copied to the macro-variable MVage, but that the TEXT "AGE" is now the value of the macro-variable.&lt;BR /&gt;
Then the Data Step is processed :&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_ ;&lt;BR /&gt;
   SET sashelp.class ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
&lt;BR /&gt;
Then the &amp;amp;MVage in the WHERE clause is transformed :&lt;BR /&gt;
&amp;amp;MVage --&amp;gt; AGE&lt;BR /&gt;
&lt;BR /&gt;
So at the end, the executed PRINT procedure is :&lt;BR /&gt;
PROC PRINT DATA = sashelp.class (WHERE = (age &amp;gt; age)) ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
&lt;BR /&gt;
As the condition is always false (a value can't be &amp;gt; than itself !), nothing is printed.&lt;BR /&gt;
&lt;BR /&gt;
I think that's why your way of doing should never come to a correct result.&lt;BR /&gt;
&lt;BR /&gt;
But why using macro-language in that case ? Just skip the macro-things and try just this :&lt;BR /&gt;
&lt;BR /&gt;
data result.agtxti_critpi /DEBUG;&lt;BR /&gt;
set agtxti_copy;&lt;BR /&gt;
dsid=open("work.probable");&lt;BR /&gt;
nobs=attrn(dsid,"nobs");&lt;BR /&gt;
do i=1 to nobs;&lt;BR /&gt;
rc = fetchobs(dsid,1);&lt;BR /&gt;
mot1=getvarc(dsid,varnum(dsid,'MOT1'));&lt;BR /&gt;
ARR_M1 = (index(txtaga||txtagb,mot1)+index(txtagc||txtagd,mot1)+index(txtage||txtagf,mot1));&lt;BR /&gt;
end;&lt;BR /&gt;
dsid=close(dsid);&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 24 Nov 2006 14:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/search-words-in-table-index/m-p/1847#M821</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2006-11-24T14:01:14Z</dc:date>
    </item>
  </channel>
</rss>

