> I know I can preprocess the data before calling IML, but I would like to find a way to filter the incoming data directly in IML.
When programmers want to do "filter ...directly in IML," it is often because the value you are trying to filter is not known prior to running the IML program. Rather, it is produced during the program.
As you have discovered, the WHERE option on the USE statement in IML does not support the same options as the WHERE option for the DATA= option in Base SAS. I suggest you use the SUBMIT/ENDSUBMIT block to call the DATA step from within your IML program to mark or filter the data. If necessary, you can pass a parameter that indicates the value you are using to filter the data.
For example, the following program uses the SUBMIT/ENDSUBMIT block to exclude all students whose names begin with the previs "Al":
proc iml;
Str = "Al"; /* string to search for */
Len = nleng(Str); /* length of string */
submit Str Len; /* send parameters to Base SAS */
data _Filter / view=_Filter; /* create data VIEW */
set sashelp.class;
/* use subsetting IF stament to exclude certain obs */
if substr(Name, 1, &Len) ^= "&Str";
run;
endsubmit;
use _Filter;
read all var "name";
close;
print name;
If, fo some reason, you don't want to use the subsetting IF statement to exclude the obs, you can create an indicator variable in the DATA step such as
_Include = (substr(Name, 1, &Len) ^= "&Str");
and then in your IML program use the syntax
use _Filter where(_Include=1);