How to select only those records that have the word "AND" with single or multiple spaces before and after it.
Standarad
Standarad And Poor
Standarad and Poor
So would like to select the only :
if index(upcase(varname), ' AND ');
You would have to handle separately any cases where And is the first word, and so does not appear with a leading space.
You could use WHERE instead of IF (especially if you are subsetting as part of a SAS procedure).
data have; input text:&$200.; if prxmatch('m/\sand\s*/i',strip(text)); cards; Standarad Standarad And Poor Standarad and Poor ;
the 'i' modifier in the findw function ignores the case.
data want; set have; if findw(varname,'and',' ','i'); run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Save the date!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.