Hello, I've stumbled upon some IF IN () syntax that works, but I cannot find any documentation as to why or how it works and I would like to learn more. I'm using SAS 9.4 on windows, here's my code and results: *using the cars dataset from sashelp;
data cars; set sashelp.cars;
run;
*this is one of the normal ways I would create a flag for specific values in the variable MAKE;
data cars; set cars;
flag=make in ("Acura" "Mazda" "Toyota");
run;
*This is the new way that I found to make a flag for specific values in the variable MAKE;
*the best way I can describe it - placing the variable name as the first term creates an array; *that the rest of the IN statement searches over for the remaining terms;
data cars; set cars;
flag2=0;
if in (strip(make),"Acura","Mazda","Toyota") then flag2=1;
run;
proc freq data=cars;
table flag*flag2*make/list missing;
run; here are the results from the frequency: As you can see, flag2 correctly identified the same values as flag. This code seems to work, but I would like to be sure it will work in other situations by reviewing the documentation. Again, I have been searching online without any success. Has anyone else used this syntax or found any documentation? Thank you!
... View more