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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 969 views
  • 2 likes
  • 3 in conversation