<?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: Macro variable value with percents in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737574#M229966</link>
    <description>&lt;P&gt;Use %NRBQUOTE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input visit $;
datalines;
%UNS%
%NO%
%HI%
;
run;

%let searchterm = %nrbquote(%UNS%);

%put &amp;amp;searchterm.;

data want;
set have (where = (visit like "&amp;amp;searchterm"));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs visit 
1 %UNS% 
&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://v8doc.sas.com/sashtml/macro/z4bquote.htm" target="_self"&gt;https://v8doc.sas.com/sashtml/macro/z4bquote.htm&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Apr 2021 13:38:04 GMT</pubDate>
    <dc:creator>maguiremq</dc:creator>
    <dc:date>2021-04-28T13:38:04Z</dc:date>
    <item>
      <title>Macro variable value with percents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737567#M229960</link>
      <description>&lt;P&gt;hi, im trying to create a macro variable containing a search term such as %UNS%.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will need to use this search term many times throughout the program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;%let searchterm=%UNS%;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data out;&lt;/P&gt;&lt;P&gt;set in (where=(visit like "&amp;amp;searchterm")) ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that the % is messing things up. How can I use such a macro variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 13:18:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737567#M229960</guid>
      <dc:creator>kalbo</dc:creator>
      <dc:date>2021-04-28T13:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with percents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737571#M229963</link>
      <description>&lt;P&gt;%let searchterm=%nrstr(%%)UNS%nrstr(%%);&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 13:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737571#M229963</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-28T13:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with percents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737572#M229964</link>
      <description>&lt;P&gt;%let searchterm=%nrstr(&amp;nbsp; %F%&amp;nbsp; );&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data out;&lt;BR /&gt;set sashelp.heart (where=(sex like "&amp;amp;searchterm")) ;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 13:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737572#M229964</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-04-28T13:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with percents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737574#M229966</link>
      <description>&lt;P&gt;Use %NRBQUOTE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input visit $;
datalines;
%UNS%
%NO%
%HI%
;
run;

%let searchterm = %nrbquote(%UNS%);

%put &amp;amp;searchterm.;

data want;
set have (where = (visit like "&amp;amp;searchterm"));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs visit 
1 %UNS% 
&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://v8doc.sas.com/sashtml/macro/z4bquote.htm" target="_self"&gt;https://v8doc.sas.com/sashtml/macro/z4bquote.htm&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 13:38:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737574#M229966</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-04-28T13:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with percents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737575#M229967</link>
      <description>&lt;P&gt;Why not just include the quotes in the macro variable?&amp;nbsp; The macro processor ignores strings bounded on the outside by single quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let searchterm='%UNS%';
data out;
  set in (where=(visit like &amp;amp;searchterm )) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use a different search method.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let searchterm=UNS;
data out;
  set in (where=(index(visit,"&amp;amp;searchterm")) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 13:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737575#M229967</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-28T13:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with percents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737577#M229969</link>
      <description>Tom,&lt;BR /&gt;Good idea. But That is not readable for some user .</description>
      <pubDate>Wed, 28 Apr 2021 13:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-percents/m-p/737577#M229969</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-04-28T13:49:19Z</dc:date>
    </item>
  </channel>
</rss>

