If you think of the markers h, min., etc. as delimiters, you can use the FIND function to locate them, then the SUBSTRN function to pick out the text values between them. Here I used the INPUT function to convert the text values to numeric values to assign to the result variables.
data _null_;
do string = "14h 20min. 2sec. ", "0h 5min. 50sec. ";
dlmat1 = find(string, "h ");
dlmat2 = find(string, "min. ");
dlmat3 = find(string, "sec.");
if dlmat1 > 0 and dlmat2 > 0 and dlmat3 > 0 then do;
hour = input(substrn(string, 1, dlmat1 - 1), ?? f8.);
minute = input(substrn(string, dlmat1 + 2, dlmat2 - dlmat1 - 2), ?? f8.);
second = input(substrn(string, dlmat2 + 5, dlmat3 - dlmat2 - 5), ?? f8.);
put (hour minute second) (=);
end;
end;
run;
hour=14 minute=20 second=2
hour=0 minute=5 second=50
... View more