Last active
August 16, 2023 10:35
-
-
Save mgao6767/111ad36f7f8c5f8840fbbbd2c4b8c44c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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