Method 1:
proc contents data=cars short out=outds00;
run;
data outds(keep=name);
set outds00;
vnam=substr(name, 1, 1);
if vnam ne "M" then output;
run;
proc transpose data=outds out=outds01(drop=_name_ _label_);
id name;
run;
data outds02(drop= drivetrain origin type rename=(_drivetrain=drivetrain _origin=origin _type=type));
set outds01;
_drivetrain=put(drivetrain, $5.0);
_origin=put(origin, $6.0);
_type=put(type, $6.0);
run;
proc append base=outds02 data=cars force;
run;
Method 2:
proc contents data=cars noprint out=vars(keep=name);
run;
data vars2;
set vars;
length vnames $200;
if substr(name, 1, 1)="M" then vnames=catx(" ",vnames, name);
retain vnames;
call symput("vnames", vnames);
run;
data cars2(drop=&vnames) cars3(keep=&vnames);
set cars;
run;
Method 33:
proc sql;
select name into: vars separated by "," from
dictionary.columns
where upcase(libname) = "WORK" and upcase(memname)="CARS" and substr(name, 1, 2)="In";
alter table cars
drop &vars;
quit;