Can someone please suggest SAS functions that are equivalent to the following Teradata functions?
EDITDISTANCE
REGEXP_REPLACE
POSITION
REGEXP_INSTR
OREPLACE
@ijm_wf wrote:
Can someone please suggest SAS functions that are equivalent to the following Teradata functions?
EDITDISTANCE
REGEXP_REPLACE
POSITION
REGEXP_INSTR
OREPLACE
Please provide explanation of what those functions do.
From the names I would guess that POSITION is probably INDEX or FIND (or INDEXW or FINDW).
No idea what the O in OREPLACE means but perhaps that is like the TRANWRD function?
There is a whole series perl regular expression functions in SAS.
SAS provides functions COMPGED, COMPLEV, and STEPIS for computing edit distances.
SAS main REGEX functions are called PRXPARSE, PRXMATCH, and PRXCHANGE.
@Tom and @Reeza have already responded with the correct suggestions wrt POSITION, OREPLACE, and REGEX*.
In Teradata, EDITDISTANCE computes the Damerau–Levenshtein distance between two strings, which is the minimal number of certain operations required to change one string into the other. SAS has 3 functions that do this type of job: SPEDIS, COMPLEV, and COMPGED. COMPLEV looks the closest since it computes the Levenshtein edit distance - but not quite, since the Damerau–Levenshtein algorithm adds the transposition operation to the classic Levenshtein.
The SAS documentation doesn't say whether COMPLEV computes the classic Levenshtein or Damerau–Levenshtein. If it's the latter, then EDITDISTANCE in Teradata is equivalent to COMPLEV in SAS. If it's the former, then COMPLEV is not it. However, I strongly suspect that the COMPGED function (GED=Generalized Edit Distance) has the arguments and flexibility to cover the Damerau–Levenshtein algorithm, and then some.
Kind regards
Paul D.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.