RenaeQuery 1:
i am Having Datasets in work some are having 0 obs how can i drop all the tables
Ex:
Dset obs
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
Query 2:
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.
Dataset x;
obs
1 Main Dataset
Q1:
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;
Q2:
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;
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
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.
Well, This is my attempt trying to be somebody.
data _x;name='asa';run;
data _y;name='asdsda';run;
data _z;name='dsda';run;
proc sql NOPRINT;
select cats(memname,'(obs=1)') into :memname SEPARATED BY ' ' from dictionary.tables where libname='WORK';
data have;
length name $10.;
set &MEMNAME indsname=dsn;
dsname=scan(dsn,-1,'.');
run;
proc sql NOPRINT;
select cats(dsname,'=',name) into: change separated by ' ' from have;
proc datasets library=work nolist;
change &change;
quit;
Thanks, Ksharp for the insight!
Haikuo
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.