In reply to Daniel.

If I understand the question, you have two sets, one with N1 items and the other with N2 items. You are trying to
find the unique enumerations of three items where i items (0<=i<=N1) are from the first set and j items (0<=j<=N2) are from the second set. So you want to find integer points (i,j) that satisfy the constraints
i+j = 3
0 <= i <= N1
0 <= j <= N1
You can solve this as a feasibility problem or by enumerating all (i,j) pairs where 0 <= i <= N1 and 0 <= j <= N1, and then searching the space for solutions where i+j=3.

proc iml;
N1 = 0:2;
N2 = 0:3;
G = ExpandGrid(N1, N2); /* all (i,j) pais */
idx = loc( G[,+]=3 ); /* find those for which i+j=3 */
Soln = G[idx, ];
print soln;