<?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: referencing the macro variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/referencing-the-macro-variable/m-p/696638#M25289</link>
    <description>&lt;P&gt;UCLA introductory tutorial on macro variables and macros&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Tutorial on converting a working program to a macro&lt;BR /&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Examples of common macro usage&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Nov 2020 18:42:43 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-11-04T18:42:43Z</dc:date>
    <item>
      <title>referencing the macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/referencing-the-macro-variable/m-p/696582#M25277</link>
      <description>&lt;P&gt;Given the SAS program shown below:&lt;/P&gt;
&lt;PRE id="yui_3_17_2_1_1604507014139_77"&gt;%let category=Upper;&lt;BR /&gt;
data work.totals;
&amp;nbsp; &amp;nbsp;set libr.input;
&amp;nbsp; &amp;nbsp;if range eq &lt;I&gt;&amp;lt;&lt;STRONG&gt;enter text here&amp;gt;&lt;/STRONG&gt;&lt;/I&gt; then amount=4000;
&amp;nbsp; &amp;nbsp;else amount= 2000;
run;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;In the space below, the code required to reference the macro variable defined in the program.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;please give me the solution with little explanation&amp;nbsp;. thanks in advance.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 16:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/referencing-the-macro-variable/m-p/696582#M25277</guid>
      <dc:creator>librasonali</dc:creator>
      <dc:date>2020-11-04T16:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: referencing the macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/referencing-the-macro-variable/m-p/696587#M25278</link>
      <description>&lt;P&gt;Assuming range is a character variable, you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if range eq "&amp;amp;category" then amount=4000;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Explanation: I had to guess, the problem isn't completely clear to me, maybe the above doesn't work. Maybe I need more information about the problem. If that works, then that's how you would refer to a macro variable &amp;amp;CATEGORY so you can test if a data step character variable has the same value as the macro variable, as you have to put the value in single or double quotes to compare it to a data step character variable; and single quotes can't be used with a macro variable inside, because then the macro variable won't resolve, so it has to be double quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 16:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/referencing-the-macro-variable/m-p/696587#M25278</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-04T16:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: referencing the macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/referencing-the-macro-variable/m-p/696590#M25280</link>
      <description>&lt;P&gt;If the above code works, then I gave a pretty weak explanation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To have any comparison work in a DATA step, without macro variables you need something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if range eq "Upper" then amount=4000;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes range is a character variable and you want to test to see if its value is "Upper". Single quotes work here too. This is an important first step, getting code to work in one situation without using macro and without macro variables. If you don't have this working, then STOP RIGHT THERE and get this to work. If you don't have this working, then anything you do with macro will not work either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now that you have that working, to use the macro variable, you must use double-quotes and you place the macro variable inside the double quotes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if range eq "&amp;amp;category" then amount=4000;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 16:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/referencing-the-macro-variable/m-p/696590#M25280</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-04T16:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: referencing the macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/referencing-the-macro-variable/m-p/696638#M25289</link>
      <description>&lt;P&gt;UCLA introductory tutorial on macro variables and macros&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Tutorial on converting a working program to a macro&lt;BR /&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Examples of common macro usage&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 18:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/referencing-the-macro-variable/m-p/696638#M25289</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-11-04T18:42:43Z</dc:date>
    </item>
  </channel>
</rss>

