BookmarkSubscribeRSS Feed
sas_Forum
Calcite | Level 5

deleteing the obs

Hi I am having 5 crores obs obs with 80 variables i want to delete the obs.I have tryed
delete * from but it was taking more time.


I have tryed

data want;
set want(obs=0);
run;

it works but is there any alternate to delete the obs from the table at once
as truncate table.

Is there any thing like truncate table in sas

6 REPLIES 6
Ksharp
Super User

Did you want to create a null table without any one obs?

proc sql;

create table want like sashelp.class;

quit;

Ksharp

sas_Forum
Calcite | Level 5

No Actually is there any thing to delete all the observations in a table .in a tabale i am having 5 crores of data

so i want to delete them at once how can i do .

FriedEgg
SAS Employee

So, you want to delete all 50 million rows from the dataset, leaving the same dataset containing no rows?

data foo;

input foo;

cards;

0

1

2

3

4

5

;

run;

proc sql;

create table foo like foo;

quit;

Linlin
Lapis Lazuli | Level 10

data foo;

if _n_=0 then set foo;

stop;

run;

Linlin

Patrick
Opal | Level 21

Your data step code looks o.k. to me. You could also code it like:

data want;
stop;

set want;
run;

The SQL delete * takes more time because it's actually not truncating the table but only marking rows for deletion - so it has to process all rows AND the table keeps its size.

Ksharp
Super User

As Patrick said. It will waste you lots of time.

But there is another statement to delete all obs in a table.

data class;
 set sashelp.class;
 label sex='gender';
 format weight dollar12.;
run;

proc sql;
 delete * from class;
quit;

Ksharp

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 1782 views
  • 3 likes
  • 5 in conversation