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);
Sunday, December 5, 2010
Subscribe to:
Posts (Atom)
Learn how to view SAS dataset labels without opening the dataset directly in a SAS session. Easy methods and examples included!
Quick Tip: See SAS Dataset Labels Without Opening the Data Quick Tip: See SAS Dataset Labels With...
-
1) What do you know about CDISC and its standards? CDISC stands for Clinical Data Interchange Standards Consortium and it is developed ke...
-
Comparing Two Approaches to Removing Formats and Informats in SAS Comparing Two Approaches to Removing Formats...
-
USE OF THE “STUDY DAY” VARIABLES The permissible Study Day variables (--DY, --STDY, and --ENDY) describe the relative day of the observ...