title: Passing a substring (may contains quotes and so on) to a macro variable
body: <p>As we know, special characters should be masked during macro compilation. But what if I wanna assign a dynamic substring to a macro variable? Like this:</p>
  
  <pre><code>%let mvSubstr = %substr(&amp;mvString, 1, 1);
  </code></pre>
  
  <p><code>mvString</code> can contain any symbols including unmatched single or double quotation marks.</p>
  
  <p>So, in this example program works correctly:</p>
  
  <pre><code>%lev mvString = Test;
  %let mvSubstr = %substr(&amp;mvString, 1, 1);
  </code></pre>
  
  <p>And in the following case program doesn't work and SAS reports <code>ERROR: Literal contains unmatched quote.</code>:</p>
  
  <pre><code>%lev mvString = %str(%'Test%');
  %let mvSubstr = %substr(&amp;mvString, 1, 1);
  </code></pre>
  
  <p>How can I defeat this problem (make program works independently of <code>mvString</code> value)?</p>