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; 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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