Is there a way to change the letters in a variable name from uppercase to lowercase?
Thank you!
Use the RENAME statement in PROC DATASETS (avoiding recreating the data set):
data have;
myvar = 0;
run;
data _null_;
set have;
put _all_;
run;
proc datasets lib=work nolist;
modify have;
rename myvar=MYVAR;
run;
quit;
data _null_;
set have;
put _all_;
run;
Never did it! However, rename in a datastep should work (e.g., UNTESTED:)
data sashelp.class;
set sashelp.class(rename=(name=NAME));
run;
I can't test it at the moment, but I would think that the lowcase, upcase and propcase functions could be used as well. e.g.,
data sashelp.class;
set sashelp.class(rename=(name=upcase(NAME)));
run;
I think you need %SYSFUNC, as in
data have ;
myvar = 0 ;
run ;
data want ;
set have(rename=(myvar=%sysfunc(upcase(myvar))));
put _all_ ;
run;
Use the RENAME statement in PROC DATASETS (avoiding recreating the data set):
data have;
myvar = 0;
run;
data _null_;
set have;
put _all_;
run;
proc datasets lib=work nolist;
modify have;
rename myvar=MYVAR;
run;
quit;
data _null_;
set have;
put _all_;
run;
Thanks Bob, this worked well!
How about:
data have;
input (AA BB cc) ($);
cards;
qw er ty
cd rt ty
;
proc print;run;
proc sql noprint;
select catx('=',name,lowcase(name)) into : names separated by ' '
from dictionary.columns
where libname='WORK' and memname='HAVE';
quit;
proc datasets lib=work nolist;
modify have;
rename &names;
run;
quit;
proc print;run;
Linlin
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.