title: DD MON YYYY to YYMMn6
body: <p>I am writing a program in Proc SQL. the program takes various input files, where the filenames change from month to month (i.e. myfile_YYYY_MM or mytable_YYYYMM, or mydata_YY_M). </p>
  
  <p>Most of the program is now dynamic, and the user is asked to input reporting date via a prompt when executing the program. </p>
  
  <p>The "Prompt Date" (&amp;Rep_Date.) in the code has format DD MON YYYY (31may2018), and I need to set up one macro variable transforming this value to format YYMMn6 (i.e. 201805). </p>
  
  <p>The syntax looks like this: </p>
  
  <pre><code> %let Period = input("&amp;Rep_Date."d,YYMMN.); 
  </code></pre>
  
  <p>This worked when trying to create a d9 variable, and for creating a month/year variable, like this:</p>
  
  <pre><code> %let date = "&amp;Rep_Date."d; /*Last day execution month*/
   %let year = %sysfunc(year("&amp;Rep_Date."d));
   %let month = %sysfunc(month("&amp;rep_Date."d));
  </code></pre>
  
  <p>for some reason, the same does not work when trying to format the date to YYMMn6. </p>
  
  <p>I also tried creating the variable "Period" in a temporary SAS table like this, but again no luck: </p>
  
  <pre><code> Data dates; 
   Period = input((&amp;Rep_date.,6.), yymmn6.);
   format Period yymmn6.;
   Run;
  </code></pre>
  
  <p>Any ideas on where I am going wrong?</p>