An easy way to get a variable to identify the source of data is the INDSNAME data set option.
Run this code on your data:
data abc;
set
work.abc_external_13jan2022
work.abc_internal_13jan2022
indsname=dsn
;
source=dsn;
run;
You will find a variable named Source that has the name of the data set each record comes from.
The option Indsname creates a temporary variable with the name of the data set. To have it in the output you need to assign it to another variable.
Then it is easy to select the records for other processes.
Do note that because of the way SAS stores metadata about libraries and library members such as data sets that the name is in all uppercase text.