<?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 positional parameter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-positional-parameter/m-p/164238#M300304</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's all about scoping rules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Macro variables are stored in symbol tables.&amp;nbsp; There is a global symbol table (used for the whole SAS session), and a macro can create a local symbol table which exists while the macro is executing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your macro creates a local symbol table to hold the parameter (macro variable) TYPE.&amp;nbsp; When CALL SYMPUT executes and writes the value TRAIN to a macro variable TYPE, it needs to decide whether to write it to the local macro variable that exists named TYPE, or to the global symbol table.&amp;nbsp; The scoping rules CALL SYMPUT follows tell it to write the the macro variable TYPE in the local symbol table.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your %PUT statements outside of the macro don't resolve, because they are looking for a macro variable named TYPE in the global symbol table.&amp;nbsp; And there isn't one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data_null_'s solution explicitly tells SYMPUTX to write the macro variable TYPE to the global symbol table, accomplishing your apparent purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 17 Aug 2014 01:14:15 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2014-08-17T01:14:15Z</dc:date>
    <item>
      <title>%macro positional parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-positional-parameter/m-p/164236#M300302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%macro location(type);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput('type','Train');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;%put &amp;amp;type;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%location(Automobile)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;%put &amp;amp;type;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Two similar warnings come out:&lt;SPAN style="color: #008000;"&gt;WARNING: Apparent symbolic reference TYPE not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the first %put &amp;amp;type; should resolve to Train; the second %put &amp;amp;type; should resolve to Automobile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could anyone explain to me why I am totally wrong? Thank you guys.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Aug 2014 21:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-positional-parameter/m-p/164236#M300302</guid>
      <dc:creator>chouchou</dc:creator>
      <dc:date>2014-08-16T21:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: %macro positional parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-positional-parameter/m-p/164237#M300303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe this is what you are trying to do.&amp;nbsp; But it doesn't seen to have a point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; location(&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;type&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'type'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"&amp;amp;type"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'G'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;%mend&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;%&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #000000; background-color: #ffffff;"&gt;location&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(Auto);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: &amp;amp;=type;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Aug 2014 21:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-positional-parameter/m-p/164237#M300303</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-08-16T21:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: %macro positional parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-positional-parameter/m-p/164238#M300304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's all about scoping rules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Macro variables are stored in symbol tables.&amp;nbsp; There is a global symbol table (used for the whole SAS session), and a macro can create a local symbol table which exists while the macro is executing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your macro creates a local symbol table to hold the parameter (macro variable) TYPE.&amp;nbsp; When CALL SYMPUT executes and writes the value TRAIN to a macro variable TYPE, it needs to decide whether to write it to the local macro variable that exists named TYPE, or to the global symbol table.&amp;nbsp; The scoping rules CALL SYMPUT follows tell it to write the the macro variable TYPE in the local symbol table.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your %PUT statements outside of the macro don't resolve, because they are looking for a macro variable named TYPE in the global symbol table.&amp;nbsp; And there isn't one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data_null_'s solution explicitly tells SYMPUTX to write the macro variable TYPE to the global symbol table, accomplishing your apparent purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Aug 2014 01:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-positional-parameter/m-p/164238#M300304</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2014-08-17T01:14:15Z</dc:date>
    </item>
  </channel>
</rss>

