BookmarkSubscribeRSS Feed
JP1234
Calcite | Level 5
 

data t1;

x=1;

y=2;

z=3;

 

w

u

v



label x="this is obsolete xx " y="this obsolete is yy" z="this is zz";

run;

 

data t1 has about 500 variables. about 100have 'obsolete' in their label like x and y.

How can I drop these varibles from t1 based on labels.

Jeff

2 REPLIES 2
Reeza
Super User

SASHELP.VCOLUMNS table has information on the variables, including labels. You can compile a list of variables that have the 'obsolete' in the label and use it to drop them. 

 

Make sure to put the name of the library and data set in upper case. 

 

proc sql noprint;
select name into :drop_list separated by " "
from sashelp.vcolumn
where upcase(libname)='WORK' and upcase(memname)='HAVE' and upcase(label) like '%OBSOLETE%';;
quit;


data want;
set have;

drop &drop_list;
run;

@JP1234 wrote:
 

data t1;

x=1;

y=2;

z=3;

 

w

u

v



label x="this is obsolete xx " y="this obsolete is yy" z="this is zz";

run;

 

data t1 has about 500 variables. about 100have 'obsolete' in their label like x and y.

How can I drop these varibles from t1 based on labels.

Jeff


 

r_behata
Barite | Level 11
data t1;
attrib x label="this is obsolete xx"
	   y label="this obsolete is yy"
	   z label="this is zz";
x=1;y=2;z=3;output;
run;

proc contents data=t1 out=tmp(keep=name label) nodetails noprint;
run;


Proc Sql noprint;
	Select name into :drp_lst separated by ','
		from tmp
	where findw(label,'obsolete');

alter table t1
drop &drp_lst;

quit;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1031 views
  • 2 likes
  • 3 in conversation