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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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