Hi @NewUsrStat, try using the SUBSTR function without a length provided to read until the end of the string. Here's the test dataset I used and adjusted code:
data mydb;
input var $6.;
datalines;
20213
202212
;
run;
data db;
set mydb;
year=substr(var,1,4);
month=substr(var,5);
run;
Notice that to read in the year, you'll want to start at position 1 and read for a length of 4 characters. For the month, you'll start reading at position 5 and without the last argument provided (length), continue reading until the end of the string. This should capture both single and double digit month numbers.
... View more