If the data set is large, you may not need to read the entire data set. Instead, you can try a construct that first reads the total number of observations in the dataset. Therefore, if you want to get the latest observations:
data t;
input x;
datalines;
1
2
3
4
;
%let dsid=%sysfunc(open(t));
%let num=%sysfunc(attrn(&dsid,nlobs));
%let rc=%sysfunc(close(&dsid));
%let number = 2;
data tt;
set t (firstobs = %eval(&num.-&number.+1));
run;
source
share