BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi I have a data set

input string1 $char60. string2 $char60.
datalines;
string1=Lycanthrope
string2=Luz vagaT
output=no match
string1=When Your Heart Stops Beating
string2=When your heart stops beating
output=match
string1=155 44 string2=155 (+44)
output=match
string1=Come Mai 883
string2=Come Mai (OcraMiX_ dj) - 883
output=match

I would like SAS to output if string1 has two or more words which match with string 2 a MATCH and if there are no words matching then it should display NO MATCH.

I've tried the complev, compged, SPEDIS functions and none of these seem to be able to return the desired result. Message was edited by: celendin
1 REPLY 1
RussAlbright
SAS Employee
I think you would need to use the scan function in a do loop for string1 to parse into individual terms, then you could use substr for each term to see if it occurs in string2. It would probably be more accurate (only match complete words) to use scan on both string1 and string2. In that case you should use a data structure like an array or hash to save the terms from string1 and then look them up for a match when your scanning string2.

Russ

Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 878 views
  • 0 likes
  • 2 in conversation