You might find the MDY function beneficial when working with valid integers (converted from your text string using INPUT and the appropriate INFORMAT). And if you want to derive a DATETIME variable (for extra-credit), use a combination of DHMS and inside it MDY to get SAS to yield a numeric (internal) value representing "seconds since 1/1/1960".
Keep in mind that you can concatenate literal strings with your "variable" input data record fields or sub-fields (using either the SCAN or INDEX / FIND functions) when parsing your data. For example if you have a data-condition where only a year value is known, you may have an assignment statement (note that there is one year-value string with an imbedded alpha O character):
DATA _NULL_;
LENGTH DATESTRING $50; /* ARBITRARY LENGTH */
INPUT DATESTRING $;
FORMAT MYDATE YYMMDD10. ; /* YOU DECIDE OUTPUT FMT */
* LOGIC HERE TO TEST FOR YEAR PORTION ONLY ;
IF LENGTH(DATESTRING) IN (2,4) AND ANYALPHA(DATESTRING) = 0 THEN
MYDATE = INPUT("1/1/" !! DATESTRING,ANYDTDTE.);
/* ELSE IF
THEN ; */ ;
IF MYDATE NE . THEN PUTLOG ">INFO> TRANSLATED OKAY: " MYDATE=;
ELSE PUTLOG ">ERROR> TRANSLATED BAD - INPUT DATA FOLLOWS: " /
_INFILE_ /
">ERROR>";
DATALINES;
1992
92
2019
2O01
RUN;
Scott Barry
SBBWorks, Inc.