Hi @mk133201 and welcome to the SAS Support Communities!
You are right. The SUBSTR function returns character values and the MDY function expects numeric arguments. Therefore, these three lines of code are inconsistent:
Year=substr(YearMon,1,4);
Month=substr(YearMon,6,2);
ReportDate=MDY(Month,1,Year);
The code will work nevertheless because of automatic type conversion: Character arguments of the MDY function containing suitable digit strings like "2017" for Year would be converted to the corresponding numeric values. But this is bad practice because it would cause a note in the log saying
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
...
which should be avoided. The same type of note would be written to the log if Year and Month were numeric variables in dataset pg1.eu_occ, as the automatic character-to-numeric conversion would then occur in the two assignment statements.
A clean solution would convert the substrings explicitly by means of the INPUT function, e.g.:
Year =input(substr(YearMon,1,4),32.);
Month=input(substr(YearMon,6,2),32.);
(The informat lengths, here: 32, could also be chosen as 4 and 2, resp.)