As suggested, a regular expression will do the job:
data temp;
if _n_ = 1 then prxId + prxParse("/X(\w+?),/i");
length extracted_value $ 10;
input char_str $ 1-20;
if prxMatch(prxId, char_str) then
extracted_value = prxPosn(prxId, 1, char_str);
drop prxId;
datalines;
X20l,p5,op3
cX3z,p4,op2(1)
;
proc print data=temp noobs; run;
Remove the "i" in the pattern if the letter X at the beginning cannot be lowercase.
PG