If ALL of your variables are character variables, and NONE have a name that is longer than 31 characters, and you want to change ALL of them to be numeric variables according to your stated recode statement, and you want to keep the same variable names, then you could use a data _null_ step with arrays to write and run call execute statements to accomplish the task. If all of the above is true, then the following code can accomplish the task: /*create some example data*/ data j1; length this that something_else $12; input (this that something_else) (& $); cards; 1 y n na n/a 5 x $$"ER", 9903 no ; /*create and run some call execute statements*/ data _null_; set j1 (obs=1); array all(*) _char_; length exline $200; call execute('data j2 (drop=_:); set j1 (rename=('); exline=catt(vname(all(1)),'=_',vname(all(1))); call execute(exline); do i=2 to dim(all); exline=cat(' ',strip(vname(all(i))),'=_',strip(vname(all(i)))); call execute(exline); end; call execute('));'); do i=1 to dim(all); exline=catt('if missing(_',vname(all(i)),') or upcase(_', vname(all(i)), ') in ("NO", "N", "NA", " ",', "'$$",'"ER", 9903',"') then do;",vname(all(i)),'=0;end;else do;', vname(all(i)),'= 1; end;'); call execute(exline); end; call execute('run;'); run;
... View more