I’m using this macro to better understand and demonstrate how to do a given proc on multiple datasets with a similar name or prefix:

%macro multisort();

%do i =1 %to 3;

PROC Sort data=nbase_&i;
BY CHID;
RUN;

%end;

%mend;

%multisort;