BookmarkSubscribeRSS Feed
ijm_wf
Fluorite | Level 6

Can someone please suggest SAS functions that are equivalent to the following Teradata functions?

 

EDITDISTANCE

REGEXP_REPLACE

POSITION

REGEXP_INSTR

OREPLACE

4 REPLIES 4
Tom
Super User Tom
Super User

@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.

PGStats
Opal | Level 21

SAS provides functions COMPGED, COMPLEV, and STEPIS for computing edit distances.

 

SAS main REGEX functions are called PRXPARSE, PRXMATCH, and PRXCHANGE.

PG
Reeza
Super User
You can use TERADATA functions if you use Passthrough. Not sure about EDITDISTANCE but the rest look like regex functions. I highly recommend bookmarking this page:

https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=n01f5qrjoh9h4hn1olbdpb5pr2td.htm...

You can find the functions you need under the character matching category.
hashman
Ammonite | Level 13

@ijm_wf:

@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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1881 views
  • 5 likes
  • 5 in conversation