here is what I want to do:
I have a list of numbers stored in a macro variable, I want to find out if this list of numbers in the macro variables are all the ids or a subset of ids in a dataset.
I saw there is a vinarray function in sas help but the example is not well documented, I do not understand how it would work.
of course, I could use scan to get a id at a time and then to look it up in the dataset but I think there got be a easier way.
For me, it's unclear if you are concerned about SAS variables or SAS variable "values"? I see a reasonable example in the SAS 9.2 DOC on VINARRAY function - here:
thank you for the example. then vinarray would not meet my need since it checks if the variable is in the arrray. I want to check if the value is in the array.
You will need to parse each sub-field in "B" and check for its value in "A", or the opposite, as you require. The process can done with either SAS macro language using %SCAN and %SYSFUNC(INDEX(argument1,argument2)) or with a DATA step, using the similar CALL function SCAN and INDEX(argument1,argument2).
data _null_;
array _a[%sysfunc(countw(&id_list1))] (&id_list1);
array _b[%sysfunc(countw(&id_list2))] (&id_list2);
do k = 1 to dim(_a);
f = whichN(_a,of _b
);
if f eq 0 then do;
put 'NOTE: The value ' _a 'from id_list1 is not in id_list2.';
leave;
end;
end;
put 'NOTE: stopped at ' K=;
run;
[/pre]