<?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 and wildcards in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/488008#M15221</link>
    <description>&lt;P&gt;As a last resort, if nothing else works you can always build your string in a separate DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;call symputx('string', "'%" || "&amp;amp;c" || "%'");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then use the macro variable for comparing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;where ..... like &amp;amp;string ......;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&lt;FONT face="helvetica"&gt;Don't add quotes around &amp;amp;STRING since the quotes are built into its value.&lt;/FONT&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 18 Aug 2018 16:35:01 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-08-18T16:35:01Z</dc:date>
    <item>
      <title>macro and wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/487938#M15215</link>
      <description>&lt;P&gt;Hello.&amp;nbsp; I'm trying to run a macro with a wildcard in it.&amp;nbsp; This the my macro code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; oth(n,c,l);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;data &amp;amp;c&amp;amp;n;&lt;/P&gt;&lt;P&gt;set &amp;amp;nopilot;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;where othmedc&amp;amp;n like&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"%&amp;amp;c%"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; and med13&amp;amp;l.pn=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;keep study_id othmedc&amp;amp;n med13&amp;amp;l.pn;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; oth;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;oth&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,neuropathy,v)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Why do I get this error message:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Apparent invocation of macro NEUROPATHY not resolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is wrong with my code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Aug 2018 19:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/487938#M15215</guid>
      <dc:creator>hein68</dc:creator>
      <dc:date>2018-08-17T19:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: macro and wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/487941#M15216</link>
      <description>&lt;P&gt;I think you need to quote the % before &amp;amp;c because when &amp;amp;c resolves to neuropathy, the resolved text looks like %neuropathy macro call. This % should not be considered a macro trigger rather should be considered as text by the macro processor. Therefore quoting the % is required and the following may help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where othmedc&amp;amp;n like &lt;STRONG&gt;%str("%%&amp;amp;c%%")&lt;/STRONG&gt; and med13&amp;amp;l.pn=1;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Aug 2018 20:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/487941#M15216</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-17T20:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: macro and wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/487952#M15218</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the error/warning is because condition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where othmedc&amp;amp;n like "%&amp;amp;c%" and med13&amp;amp;l.pn=1;&lt;/CODE&gt;&lt;/PRE&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;is resolved to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where othmedc1like&amp;nbsp;"%neuropathy%"&amp;nbsp;and med13vpn=1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and when&amp;nbsp; SAS finds text &amp;gt;&amp;gt;%neuropathy&amp;lt;&amp;lt; text in double quotation marks (") so it tries to find macro named &amp;gt;&amp;gt;neuropathy&amp;lt;&amp;lt;&amp;nbsp;and since can't it gives warning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that simple workaround can be done in following way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro oth(n,c,l);

 data &amp;amp;c&amp;amp;n;

set &amp;amp;nopilot;

where othmedc&amp;amp;n like cats('%',"&amp;amp;c.",'%') and med13&amp;amp;l.pn=1;

 keep study_id othmedc&amp;amp;n med13&amp;amp;l.pn;

run;

 %mend oth;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Aug 2018 21:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/487952#M15218</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2018-08-17T21:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: macro and wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/487975#M15220</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/74483"&gt;@hein68&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Using %% will&amp;nbsp;mask the second % from the macro processor so it won't get interpreted as a token for a macro that doesn't exist.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;
data have;
  length study_id $1 othmedc1 $20 med13vpn 8;
  call missing(of _all_);
  med13vpn=1;
  othmedc1='abcd Neuropathy xyz';
  output;
  othmedc1='abcd Xeuropathy xyz';
  output;
  stop;
run;

%let nopilot=have;
%macro oth(n,c,l);
  data &amp;amp;c&amp;amp;n;
    set &amp;amp;nopilot;
    where upcase(othmedc&amp;amp;n) like %upcase("%%&amp;amp;c%%") and med13&amp;amp;l.pn=1;
    keep study_id othmedc&amp;amp;n med13&amp;amp;l.pn;
  run;

%mend oth;

%oth(1,neuropathy,v)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Aug 2018 00:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/487975#M15220</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-08-18T00:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: macro and wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/488008#M15221</link>
      <description>&lt;P&gt;As a last resort, if nothing else works you can always build your string in a separate DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;call symputx('string', "'%" || "&amp;amp;c" || "%'");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then use the macro variable for comparing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;where ..... like &amp;amp;string ......;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&lt;FONT face="helvetica"&gt;Don't add quotes around &amp;amp;STRING since the quotes are built into its value.&lt;/FONT&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Aug 2018 16:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/macro-and-wildcards/m-p/488008#M15221</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-18T16:35:01Z</dc:date>
    </item>
  </channel>
</rss>

