> This might be simple but I'm trying to rename variables in a dataset
> 1. I only want to rename the variables that begin with an 'i'
> or an 'e' and
> rename those variables to i1, i2, i3, etc. and e1, e2, e3,
> etc respectively.
> 2. I will not know the number of variables in each set.
> 3. I do not want to hard code the old variables names.
> 4. I need it to be done dynamically.
I just tested this code, which only deals with "i" variables:
ivar1='This is ivar1';
ivar2='This is ivar2';
proc datasets library=work memtype=data nolist;
contents data=test out=work.contents;
set work.contents(keep=name) end=eof;
if _N_=1 then do;
call execute('data work.renamed;');
call execute('set work.test;');
if upcase(name) eq: 'I' then do;
call execute('rename '||trim(name)||'=i'
if eof then call execute('run;');