DATA Step, Macro, Functions and more

How to identify whether the value of column has 5 or more consonants without vowel?

Reply
Contributor
Posts: 29

How to identify whether the value of column has 5 or more consonants without vowel?

[ Edited ]

Hi,


I have a string column named "Column_Test" which cotains text up to 200 characters.
I want to identify those rows/ids where "Column_Test" value has 5 or more consonants without vowel.

Could anyone help me on this ?

 

Thanks
Nikunj

Regular Contributor
Posts: 227

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Posted in reply to nikunjgattani

Load the column into an array, looping one character at a time.  Then, count the members of the array that you consider consonants.

Super User
Posts: 2,041

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Posted in reply to nikunjgattani

Hope this helps:


data have;
input Column_Test $50.;
datalines;
ABCEDIFOGUHJKLMNPQRSTVXZ
;

data want;
set have;
want=length((compress(Column_Test,'AEIOU','L')));
if want>5 then put '5 or more consonants without vowel';
run;
Respected Advisor
Posts: 3,249

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Posted in reply to nikunjgattani

Use the COUNTC function to find if there are voewls. Then use length to count the length of the string;

 

data want;
     y = 'dfktbcpl';
     nvowels=countc(y,'aeiouy');
     length=length(y);
run;
--
Paige Miller
Super User
Posts: 6,899

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Posted in reply to nikunjgattani

How will you decide whether the letter "Y" is a vowel or not?

Contributor
Posts: 29

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Posted in reply to Astounding

Objective is to find mistyping

Ex - 

looking more for things like strkct instead of strict

 

Super User
Posts: 6,899

Re: How to identify whether the value of column has 5 or more consonants without vowel?

[ Edited ]
Posted in reply to nikunjgattani

So for the exceptions, like "strengths" you are willing to inspect them to see if they are valid?  (You still need to decide whether "Y" qualifies as a vowel.  Is "tryst" a valid word or a mis-spelling?  How about "encrypts"?)

Contributor
Posts: 29

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Posted in reply to Astounding

Yes, you were correct. 'Y' should also be included as vowel.

 

I have included 'Y' in my solution. I have posted the solution too in one of the comment.

Super User
Posts: 13,876

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Posted in reply to nikunjgattani

Spaces? Punctuation? Special Characters such as @#$%^&*()_-=+.

Is this supposed to be contiguous consonants or to the above not "reset" the count.

 

Might want to provide some concrete examples and whether they meet the requirement or not.

Contributor
Posts: 29

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Objective is to find mistyping

Ex - 

looking more for things like strkct instead of strict

 

 

Yes, we have to reset the counter once it got vowel in the string and again start counting. 

We have to ignore spaces, punctuation and special character.

Super User
Posts: 23,937

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Posted in reply to nikunjgattani

There used to be a dictionary or spelling procedure. I don't know if it still exists.

Super User
Posts: 23,937

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Posted in reply to nikunjgattani

I think you're better off doing a dictionary search. You can find lists online. Flag anything not a valid word and then build your rules from there. 

Contributor
Posts: 29

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Hi,

Here we are not looking for a correct word but a mistyped word. Text
contains various places name too that are not a part of dictionary word.
We just want to capture those rows which has more than five consonants
appearing in a string continuously.
Then, we will manually review whether it is mistyped or not.
I Hope I am able explain my question.
Super User
Posts: 23,937

Re: How to identify whether the value of column has 5 or more consonants without vowel?

Posted in reply to nikunjgattani

So a mistyped word will not end up in the list and then you can check it...am I missing something?

What defines a 'mistyped' word is your actual problem.

Contributor
Posts: 29

Re: How to identify whether the value of column has 5 or more consonants without vowel?

We have to find a mistyped word.
So, to capture mistyped word we came up with a logic that any word which
doesn't have vowels in it could be mistyped.
On the top of that we added that if the count of consonants(continuous)
should be greater than 5 or more then only we call them mistyped.

*This column contains addresses.
Ask a Question
Discussion stats
  • 15 replies
  • 193 views
  • 2 likes
  • 7 in conversation