<?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 in sql statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818241#M322983</link>
    <description>&lt;P&gt;Congrats, you should be proud of yourself!&amp;nbsp; The macro language is hard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The little bit of syntax you're missing is the fact that macro variables don't resolve inside of single quotes.&amp;nbsp; If you change to double quotes, it should work fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	title 'differences';
	select foo, "&amp;amp;myvariable._myfilename only" as location
	from bar 
etc&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 15 Jun 2022 01:20:11 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2022-06-15T01:20:11Z</dc:date>
    <item>
      <title>macro variable in sql statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818228#M322977</link>
      <description>&lt;P&gt;I am working inside a macro.&amp;nbsp; Everything is running nicely and I am proud of myself for making this thing.&amp;nbsp; Going to save me some time. I&amp;nbsp;have one little thing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do an SQL statement and I select some stuff along with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'&amp;amp;myvariable._myfilename only' as location like&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	title 'differences';
	select foo, '&amp;amp;myvariable._myfilename only' as location
	from bar 
etc&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &amp;amp;myvariable. won't resolve to the value inside the quoted SQL.&lt;/P&gt;
&lt;P&gt;If when I ran the macro myvariable were ABC, I would want location to have the value 'ABC_myfilename only' in the output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried CATS and 'stuff'n and some other silly stuff.&lt;/P&gt;
&lt;P&gt;I'm guessing it's a little piece of syntax I don't know and can't find.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 23:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818228#M322977</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2022-06-14T23:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable in sql statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818241#M322983</link>
      <description>&lt;P&gt;Congrats, you should be proud of yourself!&amp;nbsp; The macro language is hard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The little bit of syntax you're missing is the fact that macro variables don't resolve inside of single quotes.&amp;nbsp; If you change to double quotes, it should work fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	title 'differences';
	select foo, "&amp;amp;myvariable._myfilename only" as location
	from bar 
etc&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jun 2022 01:20:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818241#M322983</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-06-15T01:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable in sql statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818472#M323061</link>
      <description>Really SAS?  Really?  You're going to do that to me?  Single vs double quotes.  LOL.&lt;BR /&gt;&lt;BR /&gt;Thanks a ton, works a treat.</description>
      <pubDate>Wed, 15 Jun 2022 19:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818472#M323061</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2022-06-15T19:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable in sql statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818478#M323066</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/6401"&gt;@HB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Really SAS? Really? You're going to do that to me? Single vs double quotes. LOL.&lt;BR /&gt;&lt;BR /&gt;Thanks a ton, works a treat.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Think it through.&amp;nbsp; How else so you make a string that actually has the value &amp;amp;X ?&amp;nbsp; By having the macro processor ignore strings in single quotes it is easy to prevent the macro process from messing up strings that just happen to look like macro code.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 20:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818478#M323066</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-15T20:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable in sql statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818708#M323167</link>
      <description>In many languages/programs, either double and single quotes can be used interchangeably, so as a solution double quotes didn't jump off the screen at me.  I appreciated the response that actually solved my problem.</description>
      <pubDate>Thu, 16 Jun 2022 21:04:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-sql-statement/m-p/818708#M323167</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2022-06-16T21:04:16Z</dc:date>
    </item>
  </channel>
</rss>

