BookmarkSubscribeRSS Feed
Fred_Gavin
Calcite | Level 5
Is there anyone know how to perform the data manipulation on the SAS variable name only?

So far, every time the performance that referred to a variable is on its data below the variable name. But wot if I only want to use that variable name for my purpose? ie.

TWO TWOVO TLE TLEVO TLC TLCVO
1 1
3 3
4 5
5 6

I want to delete the variable name contains 'VO', how can I do it?
Thanks
2 REPLIES 2
andreas_lds
Jade | Level 19
Examine the sashelp.vcolumn view. It contains everything you need to create a drop-statement for proc sql.
[pre]
proc sql noprint;
select name
into :kill_list separated by ','
from sashelp.vcolumn
where memname = upcase('NAME_OF_YOUR_DATASET') and index(upcase(name), 'VO') > 0;

alter table NAME_OF_YOUR_DATASET
drop &kill_list;
quit;
[/pre]

Untested.
DanielSantos
Barite | Level 11
Hello Fred.

You could access to the metadata of the the table (say with proc contents or dictionary.columns), build a macro variable with the list of the desired columns and then perform a DROP of those (always rewriting the dataset).

/* get table info */
proc contents data = YOURDATA out = _CONTENTS noprint;
run;

/* buil DROPLIST */
%let DROPLIST=;
data _null_;
set _CONTENTS;
where index(upcase(NAME),'VO'); /* Var names who contains 'VO' */
call symput('DROPLIST',catx(' ',symget('DROPLIST'),NAME));
run;

/* rewrite the dataset and drop the desired Vars */
%put &DROPLIST;
data YOURDATA;
set YOURDATA;
drop &DROPLIST;
run;

Greetings from Portugal.

Daniel Santos at www.cgd.pt
What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1096 views
  • 0 likes
  • 3 in conversation