Sas Extract Substring from String with Prxchange or Prxpson(Prxmatch(Prxparse()))
2 Solutions Posted at Bottom My Code Data Test; Extract_String = ""; My_Result1 = Prxchange(Cat("S/^. *", Extract_String, ". *$/$1/"), -1, "A1M_Pre")...
2 SOLUTIONS POSTED AT BOTTOM
My code
data test;
extract_string = "<some string here>";
my_result1 = prxchange(cat("s/^.*", extract_string, ".*$/$1/"), -1, "A1M_PRE");
my_result2 = prxchange(cat("s/^.*", extract_string, ".*$/$1/"), -1, "AC2_0M");
my_result3 = prxchange(cat("s/^.*", extract_string, ".*$/$1/"), -1, "GA3_30M");
my_result4 = prxchange(cat("s/^.*", extract_string, ".*$/$1/"), -1, "DE3_1H30M");
run;
Must Read
Desired results
Extract the number after _ but preceding M in strings that have M at the end. The result set should be:
my_result1 = ""
my_result2 = "0"
my_result3 = "30"
my_result4 = "30"