I would parse the data with a regular expression:
data have;
string='999999999K 20APR23:11:39:00 AM';
run;
data want;
prxid=prxparse('/ ([^:]*):(.*)$/');
set have;
if prxmatch(prxid,string);
period=input(prxposn(prxid,1,string),date.);
dts=dhms(period,0,0,input(prxposn(prxid,2,string),time.));
drop prxid;
format period ddmmyy10. dts datetime23.;
run;
The PRX expression looks for a blank, followed by something that is not a colon (the first capture buffer), followed by a colon (not captured), and then the rest of the string ("$" means end of string) in the second capture buffer. Once you have the parts its a piece of cake - I put the time value in the seconds parameter of DHMS(), as a SAS time value is actually the number of seconds since midnight, instead of using 3 function calls to get the hours, minutes and seconds.
Of course, if your data is in a flat file, and not in SAS data, use INPUT (replace the CARDS with the actual physical infile):
data want;
input somestring : $20. period date7. +1 time time11.;
format period ddmmyy10.;
dts=dhms(period,0,0,time);
format dts datetime23.;
cards;
999999999K 20APR23:11:39:00 AM
;run;
... View more