I usually use proc sql for that. (Proc sql; select count(*) into: xx from mydata; quit; But also proc contents works. If you had access on the dataset right before you want to know the nr of records then %sysnobs also provides this info.