05-15-2012 03:17 AM
i am Having Datasets in work some are having 0 obs how can i drop all the tables
Name1 10 obs
Name2 0 obs
Name3 40 obs
Name4 0 obs
ID1 0 obs
id2 10 obs
i want to drop the obs with 0 records as i dont know how many datasets will be there
and with Differnt names
I am having SAS DAtasets ex: x,y,z in this the first obs will have the dataset name i
want to rename the dataset name x to the name existing in first obs.
In the above ex i gave x,y,z, but i dont know the exact names how can i do it.
1 Main Dataset
05-15-2012 03:43 AM
data test; input x; datalines; 1 . . 2 . 3 ; run; data zero; set test; stop; run; data zero1; set test; stop; run; proc sql; select distinct memname into : list separated by ',' from dictionary.tables where libname='WORK' and nobs=0; drop table &list ; quit;
data x;name='asa';run; data y;name='asdsda';run; data z;name='dsda';run; proc sql noprint; select cats(' x=',name) into : x from x(obs=1); select cats(' y=',name) into : y from y(obs=1); select cats(' z=',name) into : z from z(obs=1); quit; proc datasets library=work nolist; change &x &y &z ; quit;
05-15-2012 03:58 AM
Ksharp actually i am ahving 100 datsets in that condition how can i do it as i dont know the datasets it many
be like data1 up to data200 ,a,b,c,pdf,jkh like dataset names in this how can i do
05-15-2012 06:14 AM
use dictionary.members to query the table name and wrap them into a marco variable by SQL. It is easy.
Somebody will give you example. I have to leave now.
05-15-2012 04:18 PM
Well, This is my attempt trying to be somebody.
proc sql NOPRINT;
select cats(memname,'(obs=1)') into :memname SEPARATED BY ' ' from dictionary.tables where libname='WORK';
length name $10.;
set &MEMNAME indsname=dsn;
proc sql NOPRINT;
select cats(dsname,'=',name) into: change separated by ' ' from have;
proc datasets library=work nolist;
Thanks, Ksharp for the insight!