You should look into JMP's associative array. Think of an associative array as a keyed list. You define the key and the associated values. Keys can be strings, expressions, lists, almost anything but numeric decimal values, integers are okay. See the modified script below. In other scripting languages, an associative array is called a dictionary. I use it often.
The answer is yes to your other question, add more filter variables.
Good luck.
Names Default to Here(1);
dt = Data Table("example2_modified");
decode_aa = Associative Array({1,2,5,8,9}, {20,22,55,18,9});
For(i=1, i<=nrow(dt), i++,
if (:Phase[i] =="A",
uid = :Subject_ID[i];
tid = decode_aa[ :Test_ID[i] ];
xx = dt << get rows where(:Subject_ID ==uid & :Test_ID == tid);
if(nrow(xx)==1,
:ProTest[i] = :ProTest[xx[1]]
);
); //end if Phase
); // end For i