<?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: For macro variable, under what situation I can omit ampersand? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/For-macro-variable-under-what-situation-I-can-omit-ampersand/m-p/79682#M17152</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are just a handful of cases.&amp;nbsp; Here are the ones I can think of off the top of my head.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a DATA step, CALL SYMPUT and SYMGET both expect to see the name of a macro variable.&amp;nbsp; So the ampersand should be omitted (although since it's in a DATA step, quotes would distinguish between a DATA step variable vs. a text string).&amp;nbsp; For example, both of these create a macro variable &amp;amp;SALES:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;varname='sales';&lt;/P&gt;&lt;P&gt;call symput('sales', 'Friday');&lt;/P&gt;&lt;P&gt;call symput(varname, 'Friday');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other than that, the only case I can think of is the %superq function.&amp;nbsp; It also expects the name of a macro variable.&amp;nbsp; For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;call symput('measure', 'S&amp;amp;P 500 Index');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let measure = superq(measure);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title "&amp;amp;measure";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would quote the &amp;amp;P, so that resolving &amp;amp;measure does not trigger a search for the macro variable &amp;amp;P.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Apr 2012 15:41:35 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2012-04-11T15:41:35Z</dc:date>
    <item>
      <title>For macro variable, under what situation I can omit ampersand?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-macro-variable-under-what-situation-I-can-omit-ampersand/m-p/79680#M17150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do see couple of examples that macro variables don't have ampersand in front of them when they are referenced.&lt;/P&gt;&lt;P&gt;Can you tell me under what scenario, this rule applies?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 15:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-macro-variable-under-what-situation-I-can-omit-ampersand/m-p/79680#M17150</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-04-11T15:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: For macro variable, under what situation I can omit ampersand?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-macro-variable-under-what-situation-I-can-omit-ampersand/m-p/79681#M17151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would be interested in seeing where you have found that. Any macro variable I've run across is always preceded with the ampersant. Is it possibly you are confusing a datastep automatic variable such as _n_ or _infile_ with a macro variable?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 15:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-macro-variable-under-what-situation-I-can-omit-ampersand/m-p/79681#M17151</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-04-11T15:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: For macro variable, under what situation I can omit ampersand?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-macro-variable-under-what-situation-I-can-omit-ampersand/m-p/79682#M17152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are just a handful of cases.&amp;nbsp; Here are the ones I can think of off the top of my head.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a DATA step, CALL SYMPUT and SYMGET both expect to see the name of a macro variable.&amp;nbsp; So the ampersand should be omitted (although since it's in a DATA step, quotes would distinguish between a DATA step variable vs. a text string).&amp;nbsp; For example, both of these create a macro variable &amp;amp;SALES:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;varname='sales';&lt;/P&gt;&lt;P&gt;call symput('sales', 'Friday');&lt;/P&gt;&lt;P&gt;call symput(varname, 'Friday');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other than that, the only case I can think of is the %superq function.&amp;nbsp; It also expects the name of a macro variable.&amp;nbsp; For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;call symput('measure', 'S&amp;amp;P 500 Index');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let measure = superq(measure);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title "&amp;amp;measure";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would quote the &amp;amp;P, so that resolving &amp;amp;measure does not trigger a search for the macro variable &amp;amp;P.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 15:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-macro-variable-under-what-situation-I-can-omit-ampersand/m-p/79682#M17152</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-04-11T15:41:35Z</dc:date>
    </item>
  </channel>
</rss>

