option VALIDVARNAME=UPCASE;
Use trhe above option statement to upcase the variable name of the SAS dataset irrespective of type of variable in the dataset (character or numeric).
The following example shows how the option sattement VALIDVARNAME=UPCASE works.
proc contents data=sashelp.class out=test;
run;
Note: Propcase variable names.
*Upcasing the variables;
option validvarname=upcase;
proc sort data=sashelp.class out=test; run;
Because of the option statement. Ex: 'Age' becomes 'AGE' and 'Height' becomes 'HEIGHT' etc.
See the SAS Language Reference dictionary to get more details.
Another way to do this is to use a macro and I call it as UPCASE macro.
proc sort data=sashelp.class out=test;
by name;
run;
%macro upcase (lib,dsn);
*Create a macro variable with the total number of variable count;
data _null_;
set sashelp.vtable(where=(libname="&LIB" and memname="&DSN"));
call symput('nvars',nvar);
run;
*Create a macro variable with variable names;data _null_;
set sashelp.vcolumn(where=(libname="&LIB" and memname="&DSN"));
call symput(cats("var",_n_),name);
run;
proc datasets library=&LIB;
modify &DSN;
%do i = 1 %to &nvars;
rename &&var&i=%upcase(&&var&i);
%end;
;
quit;
run;
%mend;
%upcase(WORK,TEST);
Welcome to StudySAS, your ultimate guide to clinical data management using SAS. We cover essential topics like SDTM, CDISC standards, and Define.XML, alongside advanced PROC SQL and SAS Macros techniques. Whether you're enhancing your programming efficiency or ensuring compliance with industry standards, StudySAS offers practical tips and insights to elevate your clinical research expertise. Join us and stay ahead in the evolving world of clinical data.
Discover More Tips and Techniques on This Blog
Disclosure:
In the spirit of transparency and innovation, I want to share that some of the content on this blog is generated with the assistance of ChatGPT, an AI language model developed by OpenAI. While I use this tool to help brainstorm ideas and draft content, every post is carefully reviewed, edited, and personalized by me to ensure it aligns with my voice, values, and the needs of my readers.
My goal is to provide you with accurate, valuable, and engaging content, and I believe that using AI as a creative aid helps achieve that. If you have any questions or feedback about this approach, feel free to reach out. Your trust and satisfaction are my top priorities.