searching words in a string without spaces

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

searching words in a string without spaces

Hi All, good morning.

Considering I have a string "WEIGHTMANAGEMENT", is it possible in SAS to extract the words "Weight", "Manage" and "Management" without me specifying what to search but SAS producing all the possible words in a string?

 

Thanks and Regards,

Rama


Accepted Solutions
Solution
2 weeks ago
Super Contributor
Posts: 311

Re: searching words in a string without spaces

Posted in reply to Ramakanthkrovi

Ram,

It is difficult to look for meaningful words in a string by SAS programming. Perhaps a built-in dictionary might be useful. However, I wonder whether you can rephrase your requirement such that you give some N number of predefined words and look for the occurrence any such word(s) within the String. You may ask for the number of words found in each of the Strings.

regards,

DataSp

View solution in original post


All Replies
Super User
Posts: 6,011

Re: searching words in a string without spaces

Posted in reply to Ramakanthkrovi

So you also want:

 

we

man

manage

a

an

nag

age

gem

men

 

???

Occasional Contributor
Posts: 5

Re: searching words in a string without spaces

Posted in reply to Astounding

Yes, but I can restrict the number of characters per word then isn't it?

Super User
Posts: 12,148

Re: searching words in a string without spaces

Posted in reply to Ramakanthkrovi

Look very closely at your list of "words" that you need to extract. This may be possible but order of processing may be important such as If I find "management" do I continue to look for "manage".

The more similar words you want to find the more complicated something like this gets. For instance if you also have to search for "MAN" or "EIGHT".

 

Do you know the words you want to search for or are you hoping to find a generic English (or other) language parser that could decipher:

"THISISASENTENCEWITHOUTANYSPACES". A native English speaker can probably decipher that phrase but I really would hate to try to program something to do that.

 

You might provide a larger number of examples and search words to work with, and to show the desired output.

Note that if want this to work with misspellings such as "WEIGHTMANAGEMNET" that is going to make this likely an order of magnitude more complicated.

 

SAS does have tools for  more complex text processing in the SAS Text Miner module.

Esteemed Advisor
Posts: 5,131

Re: searching words in a string without spaces

Google does it:

 

Capture Google.PNG

PG
Super User
Posts: 12,148

Re: searching words in a string without spaces


PGStats wrote:

Google does it:

 

Capture Google.PNG


And how much time and $ was spent by Google to accomplish this.

I won't mention how many times Google tries to split my actual search terms incorrectly though.

Solution
2 weeks ago
Super Contributor
Posts: 311

Re: searching words in a string without spaces

Posted in reply to Ramakanthkrovi

Ram,

It is difficult to look for meaningful words in a string by SAS programming. Perhaps a built-in dictionary might be useful. However, I wonder whether you can rephrase your requirement such that you give some N number of predefined words and look for the occurrence any such word(s) within the String. You may ask for the number of words found in each of the Strings.

regards,

DataSp

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 203 views
  • 7 likes
  • 5 in conversation