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!
If you are wanting to delete rows in a certain range try this:
data two;
set one;
if 809 <= _n_ <= 868 then delete;
run;
If you are wanting to delete rows in a certain range try this:
data two;
set one;
if 809 <= _n_ <= 868 then delete;
run;
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;
@JackZ295 - Now you've taught me a new method too!
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.
Ready to level-up your skills? Choose your own adventure.