I only split it up to clearly show the process, just combine the statements:
data want;
instr="14/2/2019 6:37 PM";
wantdt=dhms(input(scan(instr,1," "),ddmmyy10.),
hour(input(scan(instr,2," "),time5.)+ifn(scan(instr,3," ")="PM","12:00"t,0)),
minute(input(scan(instr,2," "),time5.)+ifn(scan(instr,3," ")="PM","12:00"t,0)),
0);
format wantdt datetime.;
run;
Or just run an if statement on the data and add in the missing AM/PM part. The problem is you have data which does not conform to a structure, therefore you need to apply the rest of the structure. If it was me, I would look at my import agreement, see the data did not match and then reject the data for being non-compliant.
... View more