title: SAS Spool Errors with String Masking
body: <p>This is driving me mad now. I am trying to mask all the special characters in a particular line of a SAS plan file being used during a grid installation that I have pulled into a dataset:</p>
  
  <pre><code>if test_item = %str(&lt;Machine Id=%'$machine:)&amp;mach_num.%str(' Name=')&amp;mach_name.%str(%'&gt;) then end2 = end1;
  </code></pre>
  
  <p>The log is printed below. I see to be getting spool errors (possibly because something has not been masked correctly), however the <code>MPRINT</code> to the log suggests that the macro variable compilation has executed correctly.</p>
  
  <pre><code>SYMBOLGEN:  Macro variable FUNC_VAR resolves to test
  MPRINT(PLAN_FINDER):   data test_plan4;
  SYMBOLGEN:  Macro variable FUNC_VAR resolves to test
  MPRINT(PLAN_FINDER):   set test_plan3;
  MPRINT(PLAN_FINDER):   by ret_sort;
  MPRINT(PLAN_FINDER):   retain end2;
  388: LINE and COLUMN cannot be determined.
  NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
  ERROR 388-185: Expecting an arithmetic operator.
  SYMBOLGEN:  Macro variable MACH_NUM resolves to 2
  SYMBOLGEN:  Macro variable MACH_NAME resolves to Metadata Server
  76: LINE and COLUMN cannot be determined.
  NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
  ERROR 76-322: Syntax error, statement will be ignored.
  
             ________
             49
  MPRINT(PLAN_FINDER):   if test_item = &lt;Machine Id='$machine:2' Name='Metadata Server'&gt; then end2 = end1;
  MPRINT(PLAN_FINDER):   else if end1 = 1 then end2 = end1 + end2;
  MPRINT(PLAN_FINDER):   run;
  </code></pre>
  
  <p>Can anyone advise what I have done incorrectly?</p>
  
  <p>The code:</p>
  
  <pre><code>%macro test(func_var, mach_num, mach_name);
  
  data &amp;func_var._plan4;
  set &amp;func_var._plan3;
  by ret_sort;
  retain end2;
  if test_item = %str(&lt;Machine Id=%'$machine:)&amp;mach_num.%str(' Name=')&amp;mach_name.%str(%'&gt;) then end2 = end1;
  else if end1 = 1 then end2 = end1 + end2;
  run;
  
  %mend;
  
  %test(test, 2, Metadata Server);
  </code></pre>
  
  <p>Expected resolution of string in <code>test_item</code>:</p>
  
  <pre><code>&lt;Machine Id='$machine:2' Name='Metadata Server'&gt;
  </code></pre>
  
  <p>Thanks</p>