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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.