<?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: Using like operator with marco variables, not able to search for characters before value of marc in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Using-like-operator-with-marco-variables-not-able-to-search-for/m-p/714782#M27321</link>
    <description>&lt;P&gt;PLEASE post code as text not a picture.&lt;/P&gt;
&lt;P&gt;Copy from the editor (or log) and paste into a text box opened on the forum with either of the &amp;lt;/&amp;gt; or "running man" icons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is much easier to copy/paste and edit for us to make suggestions to code than to retype everything from scratch.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The FIND or INDEX functions will work in a where condition:&lt;/P&gt;
&lt;PRE&gt;%let pattern= AN;

proc print data=sashelp.class;
   where find(name,"&amp;amp;pattern.",'i')&amp;gt;0;
run;&lt;/PRE&gt;
&lt;P&gt;Find will return the starting character position number of the 'pattern', or to find value, in the string variable or value as the first argument to the function. the modifier 'i' says to ignore case, which may or may not be desired. If case sensitive then omit the ,'i' bit.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jan 2021 20:28:04 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-01-27T20:28:04Z</dc:date>
    <item>
      <title>Using like operator with marco variables, not able to search for characters before value of marco?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-like-operator-with-marco-variables-not-able-to-search-for/m-p/714753#M27319</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="helloagainoh2_1-1611775644586.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53992i4D45DF89EA584BD6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="helloagainoh2_1-1611775644586.png" alt="helloagainoh2_1-1611775644586.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi I am having trouble searching the Marco variable before the name, in this case I have a marco named ParkCode with the value OSE. I want to be able to search for %OSE% by using the marco in the where statement, but as you can see in the log I am only getting back&amp;nbsp;"%&amp;amp;ParkCode%", instead of&amp;nbsp;"%OSE%".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What could be the reason for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="helloagainoh2_2-1611775670905.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53993i6234C35CF3D8F6FB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="helloagainoh2_2-1611775670905.png" alt="helloagainoh2_2-1611775670905.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 19:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-like-operator-with-marco-variables-not-able-to-search-for/m-p/714753#M27319</guid>
      <dc:creator>helloagainoh2</dc:creator>
      <dc:date>2021-01-27T19:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using like operator with marco variables, not able to search for characters before value of marc</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-like-operator-with-marco-variables-not-able-to-search-for/m-p/714759#M27320</link>
      <description>&lt;P&gt;That's a dilemma.&amp;nbsp; I don't think there a less messy way about this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select model
    from SAShelp.cars 
    where model like "%ac%"
;
quit;

%let macvar=ac;

proc sql;
  select model
    from SAShelp.cars 
    where model like cat('%',"&amp;amp;macvar",'%')
;
quit;

proc sql;
  select model
    from SAShelp.cars 
    where model like '%'||"&amp;amp;macvar"||'%'
;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 19:44:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-like-operator-with-marco-variables-not-able-to-search-for/m-p/714759#M27320</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-01-27T19:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using like operator with marco variables, not able to search for characters before value of marc</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-like-operator-with-marco-variables-not-able-to-search-for/m-p/714782#M27321</link>
      <description>&lt;P&gt;PLEASE post code as text not a picture.&lt;/P&gt;
&lt;P&gt;Copy from the editor (or log) and paste into a text box opened on the forum with either of the &amp;lt;/&amp;gt; or "running man" icons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is much easier to copy/paste and edit for us to make suggestions to code than to retype everything from scratch.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The FIND or INDEX functions will work in a where condition:&lt;/P&gt;
&lt;PRE&gt;%let pattern= AN;

proc print data=sashelp.class;
   where find(name,"&amp;amp;pattern.",'i')&amp;gt;0;
run;&lt;/PRE&gt;
&lt;P&gt;Find will return the starting character position number of the 'pattern', or to find value, in the string variable or value as the first argument to the function. the modifier 'i' says to ignore case, which may or may not be desired. If case sensitive then omit the ,'i' bit.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 20:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-like-operator-with-marco-variables-not-able-to-search-for/m-p/714782#M27321</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-27T20:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using like operator with marco variables, not able to search for characters before value of marc</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-like-operator-with-marco-variables-not-able-to-search-for/m-p/714820#M27322</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/364863"&gt;@helloagainoh2&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just duplicate the first percent sign:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;where Species_ID like "&lt;FONT color="#00CCFF"&gt;%%&lt;/FONT&gt;&amp;amp;ParkCode%" and ...&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jan 2021 21:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-like-operator-with-marco-variables-not-able-to-search-for/m-p/714820#M27322</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-01-27T21:48:20Z</dc:date>
    </item>
  </channel>
</rss>

