How to delete every observation in each dataset in a specific lib.
PROC DELETE delete all the data set, what i need is to delete all the data set observations not the data sets it self.
Sure .Easy.
data class;set sashelp.class;run; data cars;set sashelp.cars;run; data _null_; set sashelp.vmember(where=(libname='WORK' and memtype='DATA')) end=last; if _n_ eq 1 then call execute('proc sql;'); call execute(cat('create table _',trim(memname),' like ',trim(memname),';')); if last then call execute('quit;'); run;
Xia Keshan
Here are two ways :
data class;
set sashelp.class;
stop;
run;
proc sql;
create table class like sashelp.class ;
quit;
Xia Keshan
What if the data sets have different names not a series like class1 , class2 ......
and i do not know there names in advance_ the data sets i mean_, all what i know is the lib name
You can get the table names from sashelp.vmember.
Sure .Easy.
data class;set sashelp.class;run; data cars;set sashelp.cars;run; data _null_; set sashelp.vmember(where=(libname='WORK' and memtype='DATA')) end=last; if _n_ eq 1 then call execute('proc sql;'); call execute(cat('create table _',trim(memname),' like ',trim(memname),';')); if last then call execute('quit;'); run;
Xia Keshan
Sorry, but I can´t agree.
Both solutions create a new table with the structure of another one.
This code does delete records from a data set:
Data Lib.Table;
Set Lib.Table;
Stop;
run;
Similar but not the same;
Regards
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.