DATA Step, Macro, Functions and more

Delete certain records.

Reply
Contributor
Posts: 30

Delete certain records.

I want to delete the first 3 records in MYTABLE.

What's wrong with the following code:

data mytable;

set mytable;

delete point (1 2 3);

run;

Frequent Contributor
Posts: 89

Re: Delete certain records.

this "delete point", I have never seen that ;-(

use:

data test;

set sashelp.class(firstobs=4);

run;

Respected Advisor
Posts: 3,894

Re: Delete certain records.

I prefer the solution proposes but for the sake of getting the syntax right in your code:

data mytable;

set mytable;

if _n_ in (1,2,3) then delete;

run;

Super User
Posts: 10,508

Re: Delete certain records.

Or

data mytable;

     set mytable (firstobs=4);

run;

Though I have seen LOTS of issues with

Data name;

     set name;

unless you can get the original data set back.

Trusted Advisor
Posts: 1,204

Re: Delete certain records.

Although you have multiple solutions based on above responses. Just to make sure, you are not trying to do this using point option right?

Ask a Question
Discussion stats
  • 4 replies
  • 224 views
  • 0 likes
  • 5 in conversation