Monday, February 1, 2016

How to find a character or word from a free text variable?

It is often difficult to summarize the information from a free text variable. If we do, it may require to identify / find the character or word using a SAS function.

SAS function Index() can be used for this purpose. The following statement will identify any records with the word 'PNEUMONIA' contained in the VARNAME variable.

       where index(varname, 'PNEUMONIA')>=1;

if the word we need to find has mixed lower and upper cases, we can use the upcase() function.

       where index(upcase(varname), 'PNEUMONIA')>=1;

Reference:
How can I find things in a character variable in SAS?

1 comment: