<?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 Using &amp;quot;%&amp;quot;  with a macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-quot-quot-with-a-macro-variable/m-p/34844#M6883</link>
    <description>I have been pulling my hair out with this.  I want to create a macro that submits some SQL code.  The SQL code contains a WHERE clause using the LIKE operator.  I need to include a macro variable in the LIKE string.  Here is what it looks like.&lt;BR /&gt;
&lt;BR /&gt;
%Macro MyMac(name);&lt;BR /&gt;
  Proc SQL;&lt;BR /&gt;
   Select *&lt;BR /&gt;
   From somefile&lt;BR /&gt;
   WHERE somefield LIKE "%&amp;amp;name%";&lt;BR /&gt;
%Mend;&lt;BR /&gt;
&lt;BR /&gt;
%MyMac(jeff);&lt;BR /&gt;
&lt;BR /&gt;
The resulting SQL code should look like&lt;BR /&gt;
&lt;BR /&gt;
Proc SQL&lt;BR /&gt;
Select *&lt;BR /&gt;
From somefile&lt;BR /&gt;
WHERE somefield LIKE "%jeff%";&lt;BR /&gt;
&lt;BR /&gt;
Those two percent signs are killing me.  Can anyone come up with a series of macro functions that would result in the string Im looking for?  Your help is appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Jeff</description>
    <pubDate>Tue, 29 Jul 2008 19:32:40 GMT</pubDate>
    <dc:creator>jmkroll</dc:creator>
    <dc:date>2008-07-29T19:32:40Z</dc:date>
    <item>
      <title>Using "%"  with a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-quot-quot-with-a-macro-variable/m-p/34844#M6883</link>
      <description>I have been pulling my hair out with this.  I want to create a macro that submits some SQL code.  The SQL code contains a WHERE clause using the LIKE operator.  I need to include a macro variable in the LIKE string.  Here is what it looks like.&lt;BR /&gt;
&lt;BR /&gt;
%Macro MyMac(name);&lt;BR /&gt;
  Proc SQL;&lt;BR /&gt;
   Select *&lt;BR /&gt;
   From somefile&lt;BR /&gt;
   WHERE somefield LIKE "%&amp;amp;name%";&lt;BR /&gt;
%Mend;&lt;BR /&gt;
&lt;BR /&gt;
%MyMac(jeff);&lt;BR /&gt;
&lt;BR /&gt;
The resulting SQL code should look like&lt;BR /&gt;
&lt;BR /&gt;
Proc SQL&lt;BR /&gt;
Select *&lt;BR /&gt;
From somefile&lt;BR /&gt;
WHERE somefield LIKE "%jeff%";&lt;BR /&gt;
&lt;BR /&gt;
Those two percent signs are killing me.  Can anyone come up with a series of macro functions that would result in the string Im looking for?  Your help is appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Jeff</description>
      <pubDate>Tue, 29 Jul 2008 19:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-quot-quot-with-a-macro-variable/m-p/34844#M6883</guid>
      <dc:creator>jmkroll</dc:creator>
      <dc:date>2008-07-29T19:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using "%"  with a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-quot-quot-with-a-macro-variable/m-p/34845#M6884</link>
      <description>What you need is a QUOTING function. Quoting is the art of hiding characters, preventing the macro processor to do them wrong. In that case, %NRBQUOTE seems to work out fine.&lt;BR /&gt;
[pre]&lt;BR /&gt;
WHERE name LIKE "%NRBQUOTE(%)&amp;amp;name%NRBQUOTE(%)" ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Regards.&lt;BR /&gt;
Olivier</description>
      <pubDate>Wed, 30 Jul 2008 07:45:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-quot-quot-with-a-macro-variable/m-p/34845#M6884</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-07-30T07:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using "%"  with a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-quot-quot-with-a-macro-variable/m-p/34846#M6885</link>
      <description>Thanks Olivier.  I had a feeling it would be something as simple as that.  It worked perfectly.</description>
      <pubDate>Wed, 30 Jul 2008 12:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-quot-quot-with-a-macro-variable/m-p/34846#M6885</guid>
      <dc:creator>jmkroll</dc:creator>
      <dc:date>2008-07-30T12:50:02Z</dc:date>
    </item>
  </channel>
</rss>

