IF you are going to type in literal strings to look for then a temporary array is one way to do this.
DATA Have;
INFILE DATALINES TRUNCOVER;
INPUT
Col1 $CHAR128.;
;
DATALINES;
Camry red Manual
Corolla Blue Automatic
Yugo (Yugoslavia) Manual
Tiguan Germany Automatic
Camry Blue (Japan) - Manual
Prius (America) Toyota Automatic
Volt (US) Automatic
Blue Automatic Honda Civic 4-Door
Gray Manual Accord LX 2012
;
RUN;
data example;
set have;
length car $ 20;
/* left out Volt to show how that the name must be in the temporary array to be found
and added a value not in the data to show that have a value to search for not present
does not cause problems
*/
array p(8) $ 20 _temporary_ ("Camry","Corolla","Yugo","Tiguan","Prius","Civic","Accord","Not_in_data");
do i=1 to dim(p);
if find(col1, trim(p[i]),'i')>0 then do;
Car=p[i];
leave; /* this assumes only expect/want to find one car value in col1*/
end;
end;
drop i;
run;
Note: SAS does have an IN operator but it is the equivalent of a bunch of : if var=value1 or var=value2 or var=value3 ....
Not the way your hopefully pseudo code was intended to work. Presence of a string in another is the work for Index, Indexw, Find, of Findw generally.
Exercise for the interested reader is to make a second temporary array for the "stage" equivalent text.
... View more