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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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