Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mgao6767/111ad36f7f8c5f8840fbbbd2c4b8c44c to your computer and use it in GitHub Desktop.
Save mgao6767/111ad36f7f8c5f8840fbbbd2c4b8c44c to your computer and use it in GitHub Desktop.
options mprint;
%macro lowcase(dsn);
%let dsid=%sysfunc(open(&dsn));
%let num=%sysfunc(attrn(&dsid,nvars));
%put #
data &dsn;
set &dsn(rename=(
%do i = 1 %to #
/*function of varname returns the name of a SAS data set variable*/
%let var&i=%sysfunc(varname(&dsid,&i));
&&var&i=%sysfunc(lowcase(&&var&i)) /*rename all variables*/
%end;));
%let close=%sysfunc(close(&dsid));
run;
%mend lowcase;
%lowcase(data_with_uppercase_var_names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment