title: Using %PUT to correctly format the dynamic file name
body: <p>I have a SAS script that reads in a CSV file and stores it in a SAS data set:</p>
  
  <pre><code>LIBNAME IN '\\path\Data';
  FILENAME CSV '\\path\Data\DT.csv';
  
  DATA IN.DT;
    INFILE CSV DLM=',' DSD FIRSTOBS=1;
    INPUT KEY VALUE1 VALUE2;
  RUN;
  </code></pre>
  
  <p>I want to change it such that instead of expecting the input to be named <code>DT.csv</code>, it would accept an input named <code>DT-2016-03-03-TEST.csv</code>, or whatever the current date is. In other words, I need to use a dynamic value in my <code>FILENAME</code> statement.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>%LET curday   = %SYSFUNC(day("&amp;sysdate"d));
  %LET curmonth = %SYSFUNC(month("&amp;sysdate"d));
  %LET curyear  = %SYSFUNC(year("&amp;sysdate"d));
  
  %PUT %SYSFUNC(PUTN(&amp;curday, z2.));
  
  FILENAME CSV "\\path\Data\DT-&amp;curyear-&amp;curmonth-&amp;curday-TEST.csv";
  </code></pre>
  
  <p>But the string it generates is like <code>Data\DT-2016-3-3-TEST.csv</code> rather than <code>Data\DT-2016-03-03-TEST.csv</code></p>
  
  <p>In other words, the trailing zeros are not there. What am I doing incorrectly?</p>