Reading observations that are in another dataset

I have several datasets, each containing a "subject id" column. One of the datasets includes only 1 variable, "subject id", but it doesn't store all subjects, but only those in the study, for example:

ID

1

2

5

6

9

Note that subjects 3,4,7,8 are excluded.

Now I want to read the other datasets (from some library) into matching datasets in the work library, BUT, I want to read only the rows with a "subject id" that appear in the column of the subjects dataset (above).

How do I do that ?

Let's assume the dataset of subjects in the study is called "subjects" and I want to read a dataset from library 'a' called 'safety' (which has a subject id column with all subjects and other columns)