The problem as stated has to do with what the FORMAT statement does and does not do.
1) SAS dates are numerics--the number of days since Jan 1, 1960.
2) The FORMAT statement doesn't transform anything; it merely associates a format with a variable so that, when you print or otherwise display it, it looks a certain way. Formats can be used within functions or PUT statements in order to create new character variables, but that's not what you did.
3) The error message is saying: you wanted me to associate a format with a character variable. That requires a character format, i.e., one that begins with a $. I (SAS) don't know about any format called $MMYYS.
4) To convert a character variable to a numeric variable, you need an informat--something that represents or transforms formatted character information. The output need not be a numeric, as you'll see when you look at the list of available informats. Many of them begin with a $ and thus have character strings as output.
5) SAS is consistent in its syntax: INPUT statement and INPUT function use informats, whereas PUT statement and PUT function use formats. Moreover, the PUT statement will write to a place specified by a FILE statement and the INPUT statement will get information from an INFILE-specified source.
6) As it happens, there is no MMYYS (or other MMYY*) informat.
7) Since you already have the character variable within a SAS data set, you just need to transform it using the INPUT function. There is a DDMMYYn informat--one that can handle various separators such as slash, dash and period, or none at all--and so Toloc's answer is correct.
8) Note that Toloc also attached a format to the converted date, thus making the value appear as mm/yyyy when you print it out. This has nothing to do with what happens in the statement that creates the converted date--he could have used any other date format.
9) If you want to represent the converted date differently somewhere in your output, you can override the FORMAT statement's association temporarily. For instance:
proc print data=temp2;
var convert_date;
format convert_date yymon5.;
run;
The result will be dates in the form 77NOV, etc.
data _null_;
file 'c:\stuff\nonsense.txt';
set temp2;
put convert_date date7.;
run;
Here you'll get a flat (not SAS) file containing dates in the form 01NOV77.