title: How do I invoke a macro variable inside the quoted string of a libname statement in SAS
body: <p>I have a libname that varies from year to year and I wanted to make a program that automatically adjusts for this. But in order for everything to work I have to have invoke a macro inside of the quoted string in a libname statement. How do I do this?</p>
  
  <pre><code>%macro srvyr;
  
  data work.whatever;
  
  length srvyr $4.;
  
  srvyr = (left(year(date()))-1);
  
  
  srvyr2 = "'C:\Documents and Settings\user\Desktop\sas\d"||srvyr||"a1'";
  
  
  run;
  
  %mend;
  
  %srvyr;  
  
  /*Everything above sets configures the pathname the way I need it*/
  </code></pre>
  
  <p><strong>I want to then run this:</strong></p>
  
  <pre><code>libname stuff &amp;srvyr;run;
  </code></pre>
  
  <p><strong>as if it were</strong></p>
  
  <pre><code>libname stuff 'C:\Documents and Settings\user\Desktop\sas\d2010a1';
  run;
  </code></pre>
  
  <p>How do I do this right?</p>