<?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: Index function with % and single quote in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Index-function-with-and-single-quote/m-p/959476#M374357</link>
    <description>&lt;P&gt;Mask single quotes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;index(intext, '%put(''ERROR')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;by doubling it inside single quotes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Tue, 18 Feb 2025 11:56:02 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2025-02-18T11:56:02Z</dc:date>
    <item>
      <title>Index function with % and single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Index-function-with-and-single-quote/m-p/959465#M374354</link>
      <description>&lt;P&gt;Hi, Im trying to use index function to search for the following string:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%put('ERROR&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However I&amp;nbsp; think the % with single quote (enslosed by double quote marks" is causing errors. Is there a way to search for the string without errors?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is how I used the index function:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt; index(intext, "%put('ERROR")=0&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2025 10:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Index-function-with-and-single-quote/m-p/959465#M374354</guid>
      <dc:creator>kalbo</dc:creator>
      <dc:date>2025-02-18T10:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Index function with % and single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Index-function-with-and-single-quote/m-p/959474#M374355</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/160861"&gt;@kalbo&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n09tblrxldh8k0n1kt6dkj3xlxug.htm" target="_blank" rel="noopener"&gt;%NRSTR function&lt;/A&gt;&amp;nbsp;to mask the &lt;FONT face="courier new,courier"&gt;%put&lt;/FONT&gt; keyword and place percent signs before the unmatched parenthesis and quotation mark as described in the documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
input intext $30.;
p=index(intext, "%nrstr(%put%(%'ERROR)");
put p=;
cards;
TEST%put('ERRORmore_text
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Alternatively, you can limit the %NRSTR function to the &lt;FONT face="courier new,courier"&gt;%put&lt;/FONT&gt; keyword and omit the additional percent signs:&lt;/P&gt;
&lt;PRE&gt;p=index(intext, "%nrstr&lt;FONT color="#00DD00"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/FONT&gt;%put&lt;STRONG&gt;&lt;FONT color="#00DD00"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;('ERROR");&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2025 11:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Index-function-with-and-single-quote/m-p/959474#M374355</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-02-18T11:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Index function with % and single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Index-function-with-and-single-quote/m-p/959475#M374356</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
string_to_find='%put('||"'ERROR";
intext='%put('||"'ERROR";
if index(intext, string_to_find)=0 then put 'ABC';
else put 'XYZ';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Feb 2025 11:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Index-function-with-and-single-quote/m-p/959475#M374356</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-02-18T11:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Index function with % and single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Index-function-with-and-single-quote/m-p/959476#M374357</link>
      <description>&lt;P&gt;Mask single quotes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;index(intext, '%put(''ERROR')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;by doubling it inside single quotes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2025 11:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Index-function-with-and-single-quote/m-p/959476#M374357</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-02-18T11:56:02Z</dc:date>
    </item>
  </channel>
</rss>

