<?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 with a wildcard within PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750010#M235833</link>
    <description>&lt;P&gt;1.Suggest using an OR instead of AND before the second memname as shown below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
SELECT *
FROM DICTIONARY.TABLES
where memtype = 'DATA'
and memname like "%&amp;amp;RUN.%"
OR  memname like "%TJR%";
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You may not be having any dataset with with string TJR in it.&lt;BR /&gt;I replaced TJR with CL and it worked.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jun 2021 20:29:24 GMT</pubDate>
    <dc:creator>Sajid01</dc:creator>
    <dc:date>2021-06-23T20:29:24Z</dc:date>
    <item>
      <title>Macro variable with a wildcard within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/749997#M235823</link>
      <description>&lt;P&gt;I am trying to identify a list of table containing certain values in their names (relying on an internal naming convention).&amp;nbsp; My attempt is failing and I believe it's likely a simple syntax error, but I am just not seeing it.&amp;nbsp; I am trying to use variables (second block of code below) to replicate the results received when using direct entry (first block).&amp;nbsp; Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/******************This version works*******************/&lt;BR /&gt;PROC SQL;&lt;BR /&gt;SELECT *&lt;BR /&gt;FROM DICTIONARY.TABLES&lt;BR /&gt;where memtype = 'DATA'&lt;BR /&gt;and memname like '%0621%'&lt;BR /&gt;and memname like '%TJR%';&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/******************This version does not*******************/&lt;BR /&gt;%let RUN = 0621;&lt;BR /&gt;%LET BUNDLE = TJR;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;SELECT *&lt;BR /&gt;FROM DICTIONARY.TABLES&lt;BR /&gt;where memtype = 'DATA'&lt;BR /&gt;and memname like "%&amp;amp;RUN%"&lt;BR /&gt;and memname like "%&amp;amp;BUNDLE%";&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/749997#M235823</guid>
      <dc:creator>TS_Hum</dc:creator>
      <dc:date>2021-06-23T20:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable with a wildcard within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750000#M235825</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let RUN = 0621;
%LET BUNDLE = TJR;

PROC SQL;
SELECT *
FROM DICTIONARY.TABLES
where memtype = 'DATA'
and memname like "%&amp;amp;RUN.%"
and memname like "%&amp;amp;BUNDLE.%";
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750000#M235825</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-06-23T20:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable with a wildcard within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750001#M235826</link>
      <description>&lt;P&gt;The warning you should have gotten in the log&lt;/P&gt;
&lt;PRE&gt;58   and memname like "%&amp;amp;BUNDLE%";
WARNING: Apparent invocation of macro TJR not resolved.
NOTE: No rows were selected.
59   QUIT;
&lt;/PRE&gt;
&lt;P&gt;gives you clue about it involves macro resolution and %anytext would reference a macro named Anytext.&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;%let RUN = 0621;
%LET BUNDLE = TJR;

PROC SQL;
SELECT *
FROM DICTIONARY.TABLES
where memtype = 'DATA'
and memname like "%&amp;amp;RUN%"
and memname like "%%&amp;amp;BUNDLE%";
QUIT;&lt;/PRE&gt;
&lt;P&gt;The double %% is sort of an escape to avoid the resolved value of Bundle treated as a macro call.&lt;/P&gt;
&lt;P&gt;You may need to do the same with RUN. It didn't have an issue with your explicit example because 0621 is not a valid macro name. If the value of Run was something that starts with a letter or _ underscore it will generate the same "not resolved message".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750001#M235826</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-23T20:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable with a wildcard within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750003#M235828</link>
      <description>&lt;P&gt;What did the log say?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750003#M235828</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-06-23T20:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable with a wildcard within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750006#M235831</link>
      <description>&lt;P&gt;Actually this is probably better:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let RUN = 0621;
%LET BUNDLE = TJR;

PROC SQL;
SELECT *
FROM DICTIONARY.TABLES
where memtype = 'DATA'
and memname like "%str(%)&amp;amp;RUN%str(%)"
and memname like "%str(%)&amp;amp;BUNDLE%str(%)";
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750006#M235831</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-06-23T20:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable with a wildcard within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750010#M235833</link>
      <description>&lt;P&gt;1.Suggest using an OR instead of AND before the second memname as shown below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
SELECT *
FROM DICTIONARY.TABLES
where memtype = 'DATA'
and memname like "%&amp;amp;RUN.%"
OR  memname like "%TJR%";
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You may not be having any dataset with with string TJR in it.&lt;BR /&gt;I replaced TJR with CL and it worked.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750010#M235833</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-06-23T20:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable with a wildcard within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750189#M235905</link>
      <description>That was it! Thanks so much for taking a look. It hadn't occurred to me that the wildcard in SQL happens to also match the syntax for calling a macro. My background is in SQL and VBA/VB, but I've only been into SAS for a month or so. It's taking a little while to get used to focusing as much on the log as the results window. There's nothing quite like staring at a piece of code for hours/days only to find I've missed a single character. This is the first time I actually got on a forum and asked for help. Thanks again!</description>
      <pubDate>Thu, 24 Jun 2021 13:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750189#M235905</guid>
      <dc:creator>TS_Hum</dc:creator>
      <dc:date>2021-06-24T13:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable with a wildcard within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750213#M235920</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381792"&gt;@TS_Hum&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;That was it! Thanks so much for taking a look. It hadn't occurred to me that the wildcard in SQL happens to also match the syntax for calling a macro. My background is in SQL and VBA/VB, but I've only been into SAS for a month or so. It's taking a little while to get used to focusing as much on the log as the results window. There's nothing quite like staring at a piece of code for hours/days only to find I've missed a single character. This is the first time I actually got on a forum and asked for help. Thanks again!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The SAS log is your friend.&amp;nbsp; As much as we all complain about issues we might have with the SAS log it is still the best I have seen for any programming system I have used.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 14:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-a-wildcard-within-PROC-SQL/m-p/750213#M235920</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-24T14:16:49Z</dc:date>
    </item>
  </channel>
</rss>

