<?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 How to use macro in where function using like operators in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135203#M27479</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to use the where function with like operators for data sub setting but the activity can contain anything like poultry processing, poultry slaughter, Meat processing, meat slaughter and so on, now i have to resolve the macro to poultry masking only the % sign?&amp;nbsp; Example of the code is given below, which function is best in this situation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let activity= Poultry;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL outobs= 500 NOPRINT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table work.testdata as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select var1, var2, activities&lt;/P&gt;&lt;P&gt;&amp;nbsp; from retailstore&lt;/P&gt;&lt;P&gt;&amp;nbsp; where activities like "%&amp;amp;activity%"&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the activity variable contains the following value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Poultry processing, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Meat Processing, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Poultry slaughter&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Poultry slaughter, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Meat Processing&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Ready to eat Poultry, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Poultry slaughter&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Meat Processing, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Import&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Meat slaughter, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Import, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Meat Processing&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Ready to eat meat, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Meat Processing&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Import&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Oct 2014 13:49:39 GMT</pubDate>
    <dc:creator>k26_23</dc:creator>
    <dc:date>2014-10-21T13:49:39Z</dc:date>
    <item>
      <title>How to use macro in where function using like operators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135203#M27479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to use the where function with like operators for data sub setting but the activity can contain anything like poultry processing, poultry slaughter, Meat processing, meat slaughter and so on, now i have to resolve the macro to poultry masking only the % sign?&amp;nbsp; Example of the code is given below, which function is best in this situation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let activity= Poultry;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL outobs= 500 NOPRINT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table work.testdata as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select var1, var2, activities&lt;/P&gt;&lt;P&gt;&amp;nbsp; from retailstore&lt;/P&gt;&lt;P&gt;&amp;nbsp; where activities like "%&amp;amp;activity%"&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the activity variable contains the following value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Poultry processing, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Meat Processing, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Poultry slaughter&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Poultry slaughter, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Meat Processing&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Ready to eat Poultry, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Poultry slaughter&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Meat Processing, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Import&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Meat slaughter, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Import, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Meat Processing&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Ready to eat meat, &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Meat Processing&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Import&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 13:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135203#M27479</guid>
      <dc:creator>k26_23</dc:creator>
      <dc:date>2014-10-21T13:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro in where function using like operators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135204#M27480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;give example of your data specially the activity col&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 14:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135204#M27480</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2014-10-21T14:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro in where function using like operators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135205#M27481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An alternative way is symget()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; where&amp;nbsp; find(activities,symget('&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;activity&lt;/SPAN&gt;') ) &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 14:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135205#M27481</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-10-21T14:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro in where function using like operators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135206#M27482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agree with KSharp there.&amp;nbsp; A further alternative is to put your items in a table and subquery that.&amp;nbsp; E.g:&lt;/P&gt;&lt;P&gt;data activities;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activity="Poultry Processing"; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activity="Meat processing"; output;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp; *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp;&amp;nbsp; ACTIVITY in (select distinct ACTIVITY from ACTIVITIES);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 14:35:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135206#M27482</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-10-21T14:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro in where function using like operators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135207#M27483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;activity&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Poultry processing, &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Meat Processing, &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Poultry slaughter&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Poultry slaughter, &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Meat Processing&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Ready to eat Poultry, &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Poultry slaughter&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Meat Processing, &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Import&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Meat slaughter, &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Import, &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Meat Processing&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Ready to eat meat, &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Meat Processing&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Import&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;This may occur in any combination, out of which i want to extract either poultry, meat, export, import to find out how many poultry centers (processing, slaughter, ready to eat), how many meat centers, and import, expor&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 14:49:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-in-where-function-using-like-operators/m-p/135207#M27483</guid>
      <dc:creator>k26_23</dc:creator>
      <dc:date>2014-10-21T14:49:25Z</dc:date>
    </item>
  </channel>
</rss>

