<?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 getting set to the name of the macro in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Macro-variable-getting-set-to-the-name-of-the-macro/m-p/167161#M1852</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't duplicate this. I suspect that at some point in testing this you accidentally set the value.&lt;/P&gt;&lt;P&gt;Try adding&lt;/P&gt;&lt;P&gt;%let macro_var1=;&lt;/P&gt;&lt;P&gt;before your data step and see if that still happens;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Dec 2014 19:35:30 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2014-12-31T19:35:30Z</dc:date>
    <item>
      <title>Macro variable getting set to the name of the macro</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Macro-variable-getting-set-to-the-name-of-the-macro/m-p/167160#M1851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; When I run this progrma:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set info1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if compress(upcase(a),'','cops') eq 'abc' then call symputx('macro_var1',b,'g'); &lt;STRONG&gt;/*if condition evaluates to false*/&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; run;&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put Macro var1 is: &amp;amp;macro_var1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I get Output:&lt;BR /&gt;Macro var1 is: &amp;amp;macro_var1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was expecting output:&lt;BR /&gt;Macro var1 is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i.e. the macro variable should be set to a null (blank) value. Why did the macro variable value get set to the name of the macro?&lt;BR /&gt;The dataset info1 looks like (2 by 2 matrix):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Name&amp;nbsp;&amp;nbsp; user12&lt;BR /&gt;Salary 100&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Dec 2014 19:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Macro-variable-getting-set-to-the-name-of-the-macro/m-p/167160#M1851</guid>
      <dc:creator>eagles_dare13</dc:creator>
      <dc:date>2014-12-31T19:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable getting set to the name of the macro</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Macro-variable-getting-set-to-the-name-of-the-macro/m-p/167161#M1852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't duplicate this. I suspect that at some point in testing this you accidentally set the value.&lt;/P&gt;&lt;P&gt;Try adding&lt;/P&gt;&lt;P&gt;%let macro_var1=;&lt;/P&gt;&lt;P&gt;before your data step and see if that still happens;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Dec 2014 19:35:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Macro-variable-getting-set-to-the-name-of-the-macro/m-p/167161#M1852</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-12-31T19:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable getting set to the name of the macro</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Macro-variable-getting-set-to-the-name-of-the-macro/m-p/167162#M1853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since the IF condition is false the CALL SYMPUT does not run so the macro variables value is not changed.&lt;/P&gt;&lt;P&gt;You are just seeing the value that it had before the data step ran.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jan 2015 00:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Macro-variable-getting-set-to-the-name-of-the-macro/m-p/167162#M1853</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-01-01T00:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable getting set to the name of the macro</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Macro-variable-getting-set-to-the-name-of-the-macro/m-p/167163#M1854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Both responders above have hit the nail on the head.&amp;nbsp; As your if condition is false, the call symput code is never run and thus your code never initializes the new macro variable macro_var1.&amp;nbsp;&amp;nbsp; Without initializing, it is an unknown macro variable when the put statement is run.&amp;nbsp; When this occurs, the put statement simply outputs the unknown macro variable name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This can be quickly solved by first initializing the macro variable:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let macro_var1=;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set info1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if compress(upcase(a),'','cops') eq 'abc' then call symputx('macro_var1',b,'g'); &lt;STRONG&gt;/*if condition evaluates to false*/&lt;/STRONG&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put Macro var1 is: &amp;amp;macro_var1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or by setting the variable with another symput statement when the condition is true. &lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set info1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if compress(upcase(a),'','cops') eq 'abc' then call symputx('macro_var1',b,'g'); &lt;STRONG&gt;/*if condition evaluates to false*/&lt;/STRONG&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else call symputx('macro_var1','new value','g'); &lt;STRONG&gt;/*if condition evaluates to true*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put Macro var1 is: &amp;amp;macro_var1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In either case, the macro variable will always be a known variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Jan 2015 04:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Macro-variable-getting-set-to-the-name-of-the-macro/m-p/167163#M1854</guid>
      <dc:creator>SusanHaller</dc:creator>
      <dc:date>2015-01-03T04:19:33Z</dc:date>
    </item>
  </channel>
</rss>

