BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
JackZ295
Pyrite | Level 9

Hi! I am trying to delete rows in a SAS data set that does not have data in specific rows. Is it possible to do it by including the variable for the Obs column (i.e., the variable _n_)?

 

I used the following Data Step, but it did not seem to work (rows 809-868 do not have data, and I am trying to delete those rows):

 

data two; set one; if _n_ >=809 or _n_<=868 then delete; run;

 

Any input regarding this would be much appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

If you are wanting to delete rows in a certain range try this:

data two; 
  set one; 
  if 809 <= _n_ <= 868 then delete; 
run;

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

If you are wanting to delete rows in a certain range try this:

data two; 
  set one; 
  if 809 <= _n_ <= 868 then delete; 
run;
JackZ295
Pyrite | Level 9

Thanks @SASKiwi! I realized that I could use the following code as well: 

data two;
set one;
if _N_ in (809:868) then delete;
run; 
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1440 views
  • 3 likes
  • 2 in conversation