How to apply Spedis function on a a particular word and not on the entire sentence

Reply
Frequent Contributor
Posts: 96

How to apply Spedis function on a a particular word and not on the entire sentence

Hi there,

I am trying to identify differents rows in table having a particular word e.g 'DUODENUM' or its variation such as 'DUODENAL' or 'DUODENOM'. I am trying to use spedis function. 

 

Using spedis function, I got an output which reflects that it calculates the value based on different words present before the word 'DUODENUM' and if the row contains only 'DUODENUM' then it gives the value as '0'.  

 

Can anybody suggest me an alternative function or method to identify all records have specific word 'DUODENUM' or with erroneous spelling 'DUODENOM' or 'DUODENAL'. 

data test1;
set test;
value=spedis(report, 'DUODENUM');
run;

 

Thank you in adavnce for your kind reply. 

Regards,

Deepak

Swain
Grand Advisor
Posts: 10,210

Re: How to apply Spedis function on a a particular word and not on the entire sentence

This code will set  3 flag variables with a value of 1 if any of the spellings listed appears. The value will be 0 otherwise.

 

This is a hardcoded solution and not generic to find other misspellings such as DUODENAM.

Proc freq or any procedure that does counts or sums can get the numbers of the records, where clauses with the flag variables can select the records of interest.

 

if you don't have a lot of these then you could be okay. If you were looking for a generic solution to multiple spelling issues then please say so.

 

Another option to consider might be TRANWRD and just correct them.

 

Report = tranwrd(report,'DUODENOM','DUODENUM');

Report = tranwrd(report,'DUODENAL','DUODENUM');

Frequent Contributor
Posts: 96

Re: How to apply Spedis function on a a particular word and not on the entire sentence

Hi Ballardw,

 

Thank you for your kind reply. I am looking for a generic search method to identify records having 'DUODENUM' or related words with 1-2 character typo. Once the records are flagged, I will get an idea about the different possible spellings and can convert them to correct spellling using transwrd function as advised by you. 

 

Thank you in advance for your kind guidance.

 

Regards,

Deepak

Swain
Frequent Contributor
Posts: 96

Re: How to apply Spedis function on a a particular word and not on the entire sentence

Hi Ballardw,

Can you guide me further to have sometghing generic in spite of hard code as I want to apply on a dataset having 100000 records. 

Thank you in advance for your kind reply.

Regards,

Deepak

Swain
Ask a Question
Discussion stats
  • 3 replies
  • 322 views
  • 1 like
  • 2 in conversation