2

I am trying to delete the first ten and last ten of a SAS data file But I am not able to do this. By using the code below I am able to delete the last 10 rows but not the first 10.

data b;
set a NOBS=COUNT;

if count <= 10 then delete;
if count -_n_ < 10 then delete;
run;

Can someone please help me on this and provide your suggestions.

Thanks in Advance

David Chris
  • 255
  • 4
  • 16

1 Answers1

2

Use _N_ variable with NOBS statement.

Delete first and last 5 rows in Class table:

data want;
set  sashelp.class  NOBS=COUNT;

if _n_        <= 5 then delete;
if count -_n_ <  5 then delete;
n_ = _n_;
run;
Sanek Zhitnik
  • 716
  • 1
  • 10
  • 25