<?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 marco variable in where statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-marco-variable-in-where-statement/m-p/900027#M355707</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to get var list that start with certain pattern from sample data. for example, variables start with 'Cr'. Currently I have following codes, but I was not able to utilize the macro variable that was set up for pattern, Could anyone tell me what I did wrong?&lt;/P&gt;
&lt;P&gt;```&lt;/P&gt;
&lt;P&gt;proc contents data=sashelp.baseball noprint out=_contents_;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%let np=Cr; /*macro variable for name pattern*/&lt;BR /&gt;data _contents1_;&lt;BR /&gt;set _contents_(where=(upcase(name)=:'&amp;amp;np.'));&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;```&lt;/P&gt;
&lt;P&gt;I tried "&amp;amp;np." and &amp;amp;np. and they are also not working.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2023 19:16:24 GMT</pubDate>
    <dc:creator>stataq</dc:creator>
    <dc:date>2023-10-25T19:16:24Z</dc:date>
    <item>
      <title>How to use marco variable in where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-marco-variable-in-where-statement/m-p/900027#M355707</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to get var list that start with certain pattern from sample data. for example, variables start with 'Cr'. Currently I have following codes, but I was not able to utilize the macro variable that was set up for pattern, Could anyone tell me what I did wrong?&lt;/P&gt;
&lt;P&gt;```&lt;/P&gt;
&lt;P&gt;proc contents data=sashelp.baseball noprint out=_contents_;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%let np=Cr; /*macro variable for name pattern*/&lt;BR /&gt;data _contents1_;&lt;BR /&gt;set _contents_(where=(upcase(name)=:'&amp;amp;np.'));&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;```&lt;/P&gt;
&lt;P&gt;I tried "&amp;amp;np." and &amp;amp;np. and they are also not working.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 19:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-marco-variable-in-where-statement/m-p/900027#M355707</guid>
      <dc:creator>stataq</dc:creator>
      <dc:date>2023-10-25T19:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use marco variable in where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-marco-variable-in-where-statement/m-p/900028#M355708</link>
      <description>&lt;P&gt;Macro variables don't resolve inside single quotes; you need to use double quotes.&lt;/P&gt;
&lt;P&gt;Since you are upcasing name you need to search for an uppercase "CR".&amp;nbsp; Try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let np=Cr; /*macro variable for name pattern*/
data _contents1_;
set _contents_(where=(upcase(name)=:"%upcase(&amp;amp;np)"));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2023 19:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-marco-variable-in-where-statement/m-p/900028#M355708</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-10-25T19:22:53Z</dc:date>
    </item>
  </channel>
</rss>

