title: SAS Import with Variable Folder
body: <p>I have a need to import a file from a a specific folder. This folder changes every month</p>
  <p>I created my variable</p>
  <pre><code>%let reportingmonth=&amp;sysfunc(intnx(month,&amp;sysfunc(date()),-1),yymmn6);
  </code></pre>
  <p>This will return the previous month in a YYYYMM format e.g. 202207</p>
  <p>I want to use this variable to import an xlsx file</p>
  <pre><code>   %let reportingmonth=%sysfunc(intnx(month,%sysfunc(date()),-1),yymmn6);
  %put &amp;reportingmonth;
  
  LIBNAME mywork &quot;%PATHNAME(ME)&quot; ;
  %TCPWIN ;
  RSUBMIT INHERITLIB=(mywork) ;
       OPTIONS msglevel=i VALIDVARNAME= any;
       proc import datafile=&quot;\\myfilepath\folder1\CPA\NonAccrual\&amp;reportingmonth.\CL\FinalOutput.xlsx&quot;
             dbms=xlsx replace out=CLSummaryImport;
              SHEET=&quot;Sheet1&quot;;
             getnames=yes;
       run;
  ENDRSUBMIT ;
  </code></pre>
  <p>However when I run the above I receive the below error.</p>
  <p>WARNING: Apparent symbolic reference REPORTINGMONTH not resolved. 39 dbms=xlsx replace out=CLSummaryImport; 40 SHEET=&quot;Sheet1; 41 getnames=yes; 42 run; ERROR: Physical file does not exist,
  \eagle.usaa.com\usaa\fsb\creditrisk\Credit_Policy_Analytics\NonAccrual&amp;reportingmonth.\CL\CLSummaryOutput.</p>
  <p>what have I doing wrong? Why is the file extension cutoff?</p>
  <p>Importing with the direct path and no variable works as expected.</p>