set heading off;
set feedback off;
remark Following removes blank lines from output.
set pagesize 0;
set verify off;
spool runs_to_process.lst;
select lorun from passcalibs where pass_index = 
(select pass_index from passes where process_name = 'PAD_PHYSICS_COTBEAM' and passname = '&1' and retired is null) 
intersect 
select lorun from passcalibs where pass_index = 
(select pass_index from passes where process_name = 'PAD_PHYSICS_SVXBEAM' and passname = '&2' and retired is null)
intersect
select lorun from passcalibs where pass_index = 
(select pass_index from passes where process_name = 'PROD_PHYSICS_CDF' and passname = '&3' and retired is null)
minus
select lorun from passcalibs where pass_index = 
(select pass_index from passes where process_name = 'PAD_PHYSICS_CDF' and passname = '&4' and retired is null);
quit;
