Good Afternoon everyone! So, I have got these dates which look like these:-
1980901, 1990831, 2011011, 2130801
but which mean actually 19980901, 19990831, 20011011, 20130801
Basically you need to replace first digit by 19 if the first digit is 1 and by 20 if the first digit is 2. I tried the following code, and not sure what im doing incorrect.
data test;
input date_ ;
cards;
1980901
1990831
2011011
2130801
;
run;
data want;
set test ;
LENGTH DATE1 $12 ;
if substr(date_, 1, 1) = 1 then date1 = 19||substr(date_, 2, 6) ;
ELSE IF substr(date_, 1, 1) = 2 then date1 = 20||substr(date_, 2, 6) ;
RUN;
... View more