<?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: Creating interaction variable w/ macro in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-interaction-variable-w-macro/m-p/19017#M549</link>
    <description>Thanks!  Your suggestions, along with moving the macro out of the original dataset and into a new one, did the trick.  I appreciate you taking the time to read through my code!</description>
    <pubDate>Wed, 22 Jun 2011 20:02:05 GMT</pubDate>
    <dc:creator>lgtea57</dc:creator>
    <dc:date>2011-06-22T20:02:05Z</dc:date>
    <item>
      <title>Creating interaction variable w/ macro</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-interaction-variable-w-macro/m-p/19014#M546</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am trying to create interaction variables for a regression between 4 race dummy variables and several age category variables. My plan was to create a new variable name as a combo of the two variables used and then multiple the variables together creating the interaction variable.   I've written the macro as follows:&lt;BR /&gt;
&lt;BR /&gt;
%macro interaction(var);&lt;BR /&gt;
&lt;BR /&gt;
data two; set one;&lt;BR /&gt;
minority&amp;amp;var=minority*&amp;amp;var;&lt;BR /&gt;
black_nonhisp&amp;amp;var = black_nonhisp*&amp;amp;var;&lt;BR /&gt;
Asian_nonhisp&amp;amp;var = Asian_nonhisp &amp;amp;var;&lt;BR /&gt;
other_nonhisp&amp;amp;var=other_nonhisp&amp;amp;var;&lt;BR /&gt;
&lt;BR /&gt;
%mend interaction;&lt;BR /&gt;
&lt;BR /&gt;
%interaction (_18to21);&lt;BR /&gt;
%interaction (_22to24);&lt;BR /&gt;
%interaction (_25to29);&lt;BR /&gt;
%interaction (_30to34);&lt;BR /&gt;
%interaction (_35to39);&lt;BR /&gt;
%interaction (_40to44);&lt;BR /&gt;
%interaction (_45to49);&lt;BR /&gt;
%interaction (_50to54);&lt;BR /&gt;
%interaction (_55to60);&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
When I run the program I am getting errors (below) and was hoping for a little debugging help as this is one of my first times to write a macro.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
21061  %interaction (_18to21);&lt;BR /&gt;
NOTE: Line generated by the macro variable "VAR".&lt;BR /&gt;
1       _18to21&lt;BR /&gt;
        -------&lt;BR /&gt;
        22&lt;BR /&gt;
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL,&lt;BR /&gt;
              NOTIN, OR, ^=, |, ||, ~=.</description>
      <pubDate>Wed, 22 Jun 2011 18:21:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-interaction-variable-w-macro/m-p/19014#M546</guid>
      <dc:creator>lgtea57</dc:creator>
      <dc:date>2011-06-22T18:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating interaction variable w/ macro</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-interaction-variable-w-macro/m-p/19015#M547</link>
      <description>Just to clarify, both variables are dummies.</description>
      <pubDate>Wed, 22 Jun 2011 18:41:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-interaction-variable-w-macro/m-p/19015#M547</guid>
      <dc:creator>lgtea57</dc:creator>
      <dc:date>2011-06-22T18:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating interaction variable w/ macro</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-interaction-variable-w-macro/m-p/19016#M548</link>
      <description>Looks like the lines:&lt;BR /&gt;
Asian_nonhisp&amp;amp;var = Asian_nonhisp &amp;amp;var;&lt;BR /&gt;
other_nonhisp&amp;amp;var=other_nonhisp&amp;amp;var;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
maybe should be&lt;BR /&gt;
Asian_nonhisp&amp;amp;var = Asian_nonhisp * &amp;amp;var;&lt;BR /&gt;
other_nonhisp&amp;amp;var=other_nonhisp *&amp;amp;var;&lt;BR /&gt;
&lt;BR /&gt;
in the macro definition.</description>
      <pubDate>Wed, 22 Jun 2011 19:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-interaction-variable-w-macro/m-p/19016#M548</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-06-22T19:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating interaction variable w/ macro</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-interaction-variable-w-macro/m-p/19017#M549</link>
      <description>Thanks!  Your suggestions, along with moving the macro out of the original dataset and into a new one, did the trick.  I appreciate you taking the time to read through my code!</description>
      <pubDate>Wed, 22 Jun 2011 20:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-interaction-variable-w-macro/m-p/19017#M549</guid>
      <dc:creator>lgtea57</dc:creator>
      <dc:date>2011-06-22T20:02:05Z</dc:date>
    </item>
  </channel>
</rss>

