You have no control over set B. This is not a valid gams statement, and will trigger and “Uncontrolled set entered as constant” error.
Conditions are meant to be evaluated in particular elements of the sets. sameas(A,B) is not for checking if an element of A belongs in B, rather, that an element of A being considered is the same as the element of B being considered, in a particular “instance” of the equation.
Example of sameas():
Set A /a1*a3/;
set b /a1*a3/;
parameter k(a,b);
k(a,b)$(not sameas(a,b))=1;
display k;