<?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: Find a substring in a word of document in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-a-substring-in-a-word-of-document/m-p/939094#M368785</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I need to determine if&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;txt_array[i]&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;starts with a prefix&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;So no need to use FIND for that test.&amp;nbsp; In normal SAS you canuse the colon modifier on the comparison operator to have the comparison truncated to the length of the shorter string.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So in this case use it on the IN operator.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;txt_arrya[i] in: ('ACC','DCA','DCB','DCC','CNA') &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS SAS does not care if you use spaces or commas between the items in the list of values for the IN operator.&amp;nbsp; So it will be easier if you set CODES like this :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let codes='ACC' 'DCA' 'DCB' 'DCC' 'CNA';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;since it is much easier to use macro variables with spaces than macro variables with commas.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Aug 2024 17:14:10 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-08-13T17:14:10Z</dc:date>
    <item>
      <title>Find a substring in a word of document</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-a-substring-in-a-word-of-document/m-p/939085#M368778</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I want to find a sales reference in a PDF document. The sales reference is formatted like &lt;CODE&gt;ACC/19000101/001&lt;/CODE&gt;, etc. In the document, &lt;CODE&gt;txt_array{i}&lt;/CODE&gt; represents a word. I need to determine if &lt;CODE&gt;txt_array[i]&lt;/CODE&gt; starts with a prefix such as &lt;CODE&gt;ACC&lt;/CODE&gt; or &lt;CODE&gt;DCA&lt;/CODE&gt;, which are stored in a macro variable &lt;CODE&gt;codes&lt;/CODE&gt;. I encountered an error, screenshots of the error are provided below.&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;SYMBOLGEN:  Macro variable CODES resolves to 
            'ACC','DCA','DCB','DCC','CNA'
NOTE: Line generated by the invoked macro "PROCESS_SALES".
6752                    if (symget('refcode') = "") and (find(txt_array[i],&amp;amp;codes)&amp;gt;0) then     call
                                                          ____
                                                          72
6752     ! symputx('refcode',txt_array{i});          
ERROR 72-185: The FIND function call has too many arguments.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How can I fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 15:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-a-substring-in-a-word-of-document/m-p/939085#M368778</guid>
      <dc:creator>WenjieZhou2021</dc:creator>
      <dc:date>2024-08-13T15:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Find a substring in a word of document</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-a-substring-in-a-word-of-document/m-p/939089#M368781</link>
      <description>&lt;P&gt;Hard to say exactly without full code, but it looks like you're passing multiple comma delimited quoted words to the find function, eg.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;find(txt_array[i],&amp;amp;codes)&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Becomes the following which is invalid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;find(txt_array[i],'ACC','DCA','DCB','DCC','CNA')&amp;gt;0)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the rest of your program&amp;nbsp; and requirements you could add double quotes around the variable or you may need to iterate through the codes. Unsure of requirements here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;find(txt_array[i],"&amp;amp;codes")&amp;gt;0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/411119"&gt;@WenjieZhou2021&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I want to find a sales reference in a PDF document. The sales reference is formatted like &lt;CODE&gt;ACC/19000101/001&lt;/CODE&gt;, etc. In the document, &lt;CODE&gt;txt_array{i}&lt;/CODE&gt; represents a word. I need to determine if &lt;CODE&gt;txt_array[i]&lt;/CODE&gt; starts with a prefix such as &lt;CODE&gt;ACC&lt;/CODE&gt; or &lt;CODE&gt;DCA&lt;/CODE&gt;, which are stored in a macro variable &lt;CODE&gt;codes&lt;/CODE&gt;. I encountered an error, screenshots of the error are provided below.&lt;/P&gt;
&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;SYMBOLGEN:  Macro variable CODES resolves to 
            'ACC','DCA','DCB','DCC','CNA'
NOTE: Line generated by the invoked macro "PROCESS_SALES".
6752                    if (symget('refcode') = "") and (find(txt_array[i],&amp;amp;codes)&amp;gt;0) then     call
                                                          ____
                                                          72
6752     ! symputx('refcode',txt_array{i});          
ERROR 72-185: The FIND function call has too many arguments.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How can I fix this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 15:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-a-substring-in-a-word-of-document/m-p/939089#M368781</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-08-13T15:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Find a substring in a word of document</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-a-substring-in-a-word-of-document/m-p/939094#M368785</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I need to determine if&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;txt_array[i]&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;starts with a prefix&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;So no need to use FIND for that test.&amp;nbsp; In normal SAS you canuse the colon modifier on the comparison operator to have the comparison truncated to the length of the shorter string.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So in this case use it on the IN operator.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;txt_arrya[i] in: ('ACC','DCA','DCB','DCC','CNA') &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS SAS does not care if you use spaces or commas between the items in the list of values for the IN operator.&amp;nbsp; So it will be easier if you set CODES like this :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let codes='ACC' 'DCA' 'DCB' 'DCC' 'CNA';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;since it is much easier to use macro variables with spaces than macro variables with commas.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 17:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-a-substring-in-a-word-of-document/m-p/939094#M368785</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-13T17:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Find a substring in a word of document</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-a-substring-in-a-word-of-document/m-p/939177#M368806</link>
      <description>&lt;P&gt;Thank you, it's working!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 04:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-a-substring-in-a-word-of-document/m-p/939177#M368806</guid>
      <dc:creator>WenjieZhou2021</dc:creator>
      <dc:date>2024-08-14T04:29:07Z</dc:date>
    </item>
  </channel>
</rss>

