Assuming that the records are in ascending order according to their date (and that you don't have records with month=12 and year=2014 followed by month=12 and year=2015 or so) : Data Have; Input Date $; Datalines; 1106 1209 0101 0102 ; Run; Data Want (Keep=Date_new); Set Have; Retain Year 2014 Prev_Month; If _N_ eq 1 Then Prev_Month=Input(Substr(Date,3,2),2.); Else If Input(Substr(Date,3,2),2.) < Prev_Month Then Year+1; Prev_Month=Input(Substr(Date,3,2),2.); Date_new=MDY(Put(Substr(Date,3,2),2.),Put(Substr(Date,1,2),2.),Year); Format Date_new DDMMYY8.; Run;
... View more