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). 

Most of the program is now dynamic, and the user is asked to input reporting date via a prompt when executing the program. 

The "Prompt Date" (&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). 

The syntax looks like this: 

```
 %let Period = input("&Rep_Date."d,YYMMN.); 

```

This worked when trying to create a d9 variable, and for creating a month/year variable, like this:

```
 %let date = "&Rep_Date."d; /*Last day execution month*/
 %let year = %sysfunc(year("&Rep_Date."d));
 %let month = %sysfunc(month("&rep_Date."d));

```

for some reason, the same does not work when trying to format the date to YYMMn6. 

I also tried creating the variable "Period" in a temporary SAS table like this, but again no luck: 

```
 Data dates; 
 Period = input((&Rep_date.,6.), yymmn6.);
 format Period yymmn6.;
 Run;

```

Any ideas on where I am going wrong?