A reply amongst many possible others. Suppose one wants to rename variables starting with "a" with "z"; A cat has more than 1 way to lick its paw (this is a family show). /*******************/ /*** sample data ***/ /*******************/ data t_a; input aaa aab aac pa $ pb $ pc $ @@; cards; 1 2 3 A B C 4 5 6 D E F ; run; /******************/ /*** a solution ***/ /******************/ data _null_; set t_a; length xx xy $50.; array v_num(*) _numeric_; array v_chr(*) _character_; if _N_>1 then stop; if _N_ =1 then do; call execute('proc datasets noprint; modify t_a; rename '); do i = 1 to dim(v_num); if substr(vname(v_num(i)),1,1)='a' then do; xx= compress('z'||substr(vname(v_num(i)),2)); call execute(vname(v_num(i))||'='||xx||' '); end; end; do i = 1 to dim(v_chr); if substr(vname(v_chr(i)),1,1)='a' then do; xx= compress('z'||substr(vname(v_chr(i)),2)); call execute(vname(v_chr(i))||'='||xx||' '); end; end; call execute('; quit; run;'); end; run;
... View more