I'm converting some of my R code to SQL PROC for a program in SAS EG (V8.3.2.140), however I'm stuck. I need some help extracting a alphanumeric string from a column and make a new column with that alphanumeric string.
In R I'm using a package called rebus to create a patterns, subsequently I use mutate/str_extract to place it in a new column.
The pattern looks like this:
c( optional(ALPHA) %R% ALPHA %R% ALPHA %R% DGT %R% DGT %R% ALPHA %R% ALPHA %R% optional(ALPHA) %R% DGT %R% optional(DGT) %R% optional(ALPHA) ) So an optional character, followed by a character followed by a character followed by a digits, etc. It would look like this: ABC01DE02 or ABC01DE02A. I need both versions.
The position of the alphanumeric code in the string I'm trying to extract it from can vary, so using the position won't work. The characters will always be capital letter though.
Hope this provides enough information for a solution.