<?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: cannot search using index function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/cannot-search-using-index-function/m-p/947780#M370965</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;BR /&gt;Do you have&amp;nbsp;&lt;SPAN&gt;procedure_name data to show here? There might be multiple reasons the function is not giving the expected results.&amp;nbsp;&lt;BR /&gt;Your current code assumes that the searched word comes first in the string in procedure_name variable without preceding spaces.&amp;nbsp;&lt;BR /&gt;If this assumption is true then try adding STRIP() function to your existing code.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(lowcase(&lt;STRONG&gt;strip(procedure_name)&lt;/STRONG&gt;), "defibrillator")=1 then pro_icd=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;If the string doesn't start with the searched word you can use FIND function instead. It gives you 1 if true, and the condition works.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if find(lowcase(procedure_name), "defibrillator")=1 then pro_icd=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Oct 2024 22:55:25 GMT</pubDate>
    <dc:creator>A_Kh</dc:creator>
    <dc:date>2024-10-16T22:55:25Z</dc:date>
    <item>
      <title>cannot search using index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cannot-search-using-index-function/m-p/947776#M370964</link>
      <description>&lt;P&gt;Dear SAS community&lt;/P&gt;
&lt;P&gt;I used this code to search a text field (procedure_name) but it yielded wrong data in all of the "pro_" fields.&amp;nbsp;&amp;nbsp; But the if I use .... where procedure_name contains xxx then the results make sense so I know this field has searchable text.&lt;/P&gt;
&lt;P&gt;Could you please tell me what is wrong with my code using index function?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data procedure1; set procedure;&lt;BR /&gt;pro_icd=0; pro_pacer=0; pro_emb=0; pro_cabg=0; pro_pci=0; pro_valvesurg=0; pro_codeblue=0; pro_ett=0; pro_ablation=0; pro_cor_angio=0; pro_ccta=0; pro_ccs=0;&lt;BR /&gt;if index(lowcase(procedure_name), "defibrillator")=1 then pro_icd=1;&lt;BR /&gt;if index(lowcase(procedure_name), "pacemaker")=1 then pro_pacer=1;&lt;BR /&gt;if index(lowcase(procedure_name), "biopsy of heart")=1 then pro_emb=1;&lt;BR /&gt;if indexc(lowcase(procedure_name), "bypass coronary artery","cardiac bypass graft surgery","coronary artery bypass")=1 then pro_cabg=1;&lt;BR /&gt;if index(lowcase(procedure_name), "dilation of coronary artery")=1 then pro_pci=1;&lt;BR /&gt;if index(lowcase(procedure_name), "cardiac valve replacement")=1 then pro_valvesurg=1;&lt;BR /&gt;if index(lowcase(procedure_name), "cardiopulmonary resusitation")=1 then pro_codeblue=1;&lt;BR /&gt;if index(lowcase(procedure_name), "cardiovascular stress test")=1 then pro_ett=1;&lt;BR /&gt;if index(lowcase(procedure_name), "ablation")=1 and index(lowcase(procedure_name), "heart")=1 then pro_ablation=1;&lt;BR /&gt;if indexc(lowcase(procedure_name), "coronary angiography","coronary arteriography")=1 then pro_cor_angio=1;&lt;BR /&gt;if index(lowcase(procedure_name), "heart")=1 and indexc(lowcase(procedure_name), "catheterization")=1 then pro_cor_angio=1;&lt;BR /&gt;if indexc(lowcase(procedure_name), "computed tomographic angiography, heart, coronary arteries")=1 then pro_ccta=1;&lt;BR /&gt;if index(lowcase(procedure_name), "coronary calcium")=1 then pro_ccs=1;&lt;BR /&gt;keep empi procedure_name code pro_test:;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much in advance&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2024 21:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cannot-search-using-index-function/m-p/947776#M370964</guid>
      <dc:creator>rykwong</dc:creator>
      <dc:date>2024-10-16T21:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: cannot search using index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cannot-search-using-index-function/m-p/947780#M370965</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;BR /&gt;Do you have&amp;nbsp;&lt;SPAN&gt;procedure_name data to show here? There might be multiple reasons the function is not giving the expected results.&amp;nbsp;&lt;BR /&gt;Your current code assumes that the searched word comes first in the string in procedure_name variable without preceding spaces.&amp;nbsp;&lt;BR /&gt;If this assumption is true then try adding STRIP() function to your existing code.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(lowcase(&lt;STRONG&gt;strip(procedure_name)&lt;/STRONG&gt;), "defibrillator")=1 then pro_icd=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;If the string doesn't start with the searched word you can use FIND function instead. It gives you 1 if true, and the condition works.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if find(lowcase(procedure_name), "defibrillator")=1 then pro_icd=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2024 22:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cannot-search-using-index-function/m-p/947780#M370965</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2024-10-16T22:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: cannot search using index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cannot-search-using-index-function/m-p/947798#M370970</link>
      <description>&lt;P&gt;this works!&amp;nbsp; thanks so much&lt;/P&gt;
&lt;P&gt;I should not have assume =1 because the text did not always start on the first position.&lt;/P&gt;
&lt;P&gt;very much appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 02:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cannot-search-using-index-function/m-p/947798#M370970</guid>
      <dc:creator>rykwong</dc:creator>
      <dc:date>2024-10-17T02:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: cannot search using index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cannot-search-using-index-function/m-p/947800#M370972</link>
      <description>&lt;P&gt;Index returns the position number if the text is found. So if the target text might not start on the first column of the searched text:&lt;/P&gt;
&lt;PRE&gt;if index(lowcase(procedure_name), "defibrillator") ge 1 then pro_icd=1;&lt;/PRE&gt;
&lt;P&gt;ge is greater than or equal.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 02:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cannot-search-using-index-function/m-p/947800#M370972</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-10-17T02:43:23Z</dc:date>
    </item>
  </channel>
</rss>

