Let us look at this part of your code. (I am looking at what you have shown here )
select a.id,
b.*
from (select id from loans.data_apps) a
left join
(select id, 'apps' as var1, var2, var3, var4
from loans.data_apps
) b
on a.id = b.id
I don't think you are achieving anything by this join.
Basically my understanding is that you want records from loans.data_apps that have their id's present in loans.data_collections.
With this understanding I would write a code something like this
proc sql;
select id, 'apps' as var1, var2, var3 ,var4 from load.data_apps a
where a.id in (select id from loans.data_collections);
quit;
Their will duplicate id's if loans.data_apps has duplicates.
In that case use select distinct in place of select.