<?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 Syntax Error with a Macro Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-with-a-Macro-Variable/m-p/342667#M78575</link>
    <description>&lt;P&gt;So I am trying to write a Macro to do backwards selection based on change in estimate(I know SAS has an automatic backwards selection process but it bases it off P-value). I had written a Macro for another project earlier but used proc surveylogistic then, this time I am using proc mixed. I have edited the code and thought that it should work but I am having issues with the interaction effect in proc mixed. When I assign a value to a macro variable inside a macro it doesn't like the * symbol. I get a syntax error, the weird thing is this would work fine outside of a macro. %Let Interaction = A*B; works fine but inside a %Macro if I say %Macro(explanatory = A B A*B) it complains with the error.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Another similar error is when I drop the first variable from the model it drops part of the interaction as well. AKA if I tell it to drop A, it drops the A from A*B so it becomes *B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Outside the macro my code is simply...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; proc mixed data=Input;
     	class B cat1 cat2 cat3 cat4;
     	model response = A B A*B cat1 cat2 cat3 cat4 explan1 explan2 explan3 /solution;
ods output solutionF = Sol1;
		run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Inside the macro it is&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc mixed data=&amp;amp;data;
     	class B &amp;amp;catvar;
     	model  &amp;amp;response = &amp;amp;covars /solution;
	 	ods output solutionF  = Sol&amp;amp;i;
	 run;	&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;when I get to a part&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput("rcovars", reducedlist);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where Reducedlist is the list of the model after I drop a variable I get&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, -, /, :, _ALL_,&lt;BR /&gt; _CHARACTER_, _CHAR_, _NUMERIC_.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;the * is underlined.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Main issue:&lt;/STRONG&gt; Why can't we simply make a macro variable with a * sign inside a macro and is there a solution to this? Is there some way to create a variable that counts as A*B aka C or something but not so it is referenced as A*B but rather just C?&lt;/P&gt;</description>
    <pubDate>Mon, 20 Mar 2017 16:16:00 GMT</pubDate>
    <dc:creator>Leon27607</dc:creator>
    <dc:date>2017-03-20T16:16:00Z</dc:date>
    <item>
      <title>Syntax Error with a Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-with-a-Macro-Variable/m-p/342667#M78575</link>
      <description>&lt;P&gt;So I am trying to write a Macro to do backwards selection based on change in estimate(I know SAS has an automatic backwards selection process but it bases it off P-value). I had written a Macro for another project earlier but used proc surveylogistic then, this time I am using proc mixed. I have edited the code and thought that it should work but I am having issues with the interaction effect in proc mixed. When I assign a value to a macro variable inside a macro it doesn't like the * symbol. I get a syntax error, the weird thing is this would work fine outside of a macro. %Let Interaction = A*B; works fine but inside a %Macro if I say %Macro(explanatory = A B A*B) it complains with the error.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Another similar error is when I drop the first variable from the model it drops part of the interaction as well. AKA if I tell it to drop A, it drops the A from A*B so it becomes *B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Outside the macro my code is simply...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; proc mixed data=Input;
     	class B cat1 cat2 cat3 cat4;
     	model response = A B A*B cat1 cat2 cat3 cat4 explan1 explan2 explan3 /solution;
ods output solutionF = Sol1;
		run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Inside the macro it is&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc mixed data=&amp;amp;data;
     	class B &amp;amp;catvar;
     	model  &amp;amp;response = &amp;amp;covars /solution;
	 	ods output solutionF  = Sol&amp;amp;i;
	 run;	&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;when I get to a part&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput("rcovars", reducedlist);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where Reducedlist is the list of the model after I drop a variable I get&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, -, /, :, _ALL_,&lt;BR /&gt; _CHARACTER_, _CHAR_, _NUMERIC_.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;the * is underlined.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Main issue:&lt;/STRONG&gt; Why can't we simply make a macro variable with a * sign inside a macro and is there a solution to this? Is there some way to create a variable that counts as A*B aka C or something but not so it is referenced as A*B but rather just C?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 16:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-with-a-Macro-Variable/m-p/342667#M78575</guid>
      <dc:creator>Leon27607</dc:creator>
      <dc:date>2017-03-20T16:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error with a Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-with-a-Macro-Variable/m-p/348488#M80702</link>
      <description>&lt;P&gt;* is a special character and you need to mask it when assigning to a macro variable. Try the macro function&amp;nbsp;&lt;SPAN&gt;%STR to mask&amp;nbsp;*. &amp;nbsp;Not sure how your "%Let Interaction = A*B;" works, but try to use "&lt;/SPAN&gt;%let Interaction=%str(A B A*B);". The same solution for your macro problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See more details from thel link below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://v8doc.sas.com/sashtml/macro/z3514str.htm&amp;nbsp;" target="_blank"&gt;https://v8doc.sas.com/sashtml/macro/z3514str.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it can help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 06:13:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-with-a-Macro-Variable/m-p/348488#M80702</guid>
      <dc:creator>CiCi</dc:creator>
      <dc:date>2017-04-09T06:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error with a Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-with-a-Macro-Variable/m-p/348524#M80719</link>
      <description>&lt;P&gt;Turn on MPRINT option to see what actual code you macro is generating. There is nothing wrong with what you have posted.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data=Input;
%let catvar=cat1 cat2 cat3 cat4 ;
%let response=response;
%let covars=A B A*B cat1 cat2 cat3 cat4 explan1 explan2 explan3 ;
%let i=1 ;

%macro xx ;
proc mixed data=&amp;amp;data;
  class B &amp;amp;catvar;
  model &amp;amp;response = &amp;amp;covars /solution;
ods output solutionF  = Sol&amp;amp;i;
run;	
%mend xx;
options mprint;
%xx;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which generates&lt;/P&gt;
&lt;PRE&gt;MPRINT(XX):   proc mixed data=Input;
MPRINT(XX):   class B cat1 cat2 cat3 cat4;
MPRINT(XX):   model response = A B A*B cat1 cat2 cat3 cat4 explan1 explan2 explan3 /solution;
MPRINT(XX):   ods output solutionF = Sol1;
MPRINT(XX):   run;
&lt;/PRE&gt;
&lt;P&gt;If you macro variables look like they have the right values then perhaps you need to remove any macro quoting so that it is not confusing the SAS parser.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 14:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-with-a-Macro-Variable/m-p/348524#M80719</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-09T14:56:02Z</dc:date>
    </item>
  </channel>
</rss>

