Posts

Showing posts with the label Validvarname=Upcase

Easy way to UPCASE variable names of SAS dataset

Image
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")); ...

Options VALIDVARNAME=UPCASE

VALIDVARNAME= V7 UPCASE ANY VALIDVARNAME= option is generally used in SAS whenever we want to control the SAS variable names in the dataset. VALIDVARNAME= V7 UPCASE ANY The default option will be VALIDVARNAME=V7 until we specify as UPPERCASE or ANY . When we mention options VALIDVARNAME=V7 , that means we are telling SAS to change the name of the Database column (etc EXCEL sheet column) to valid SAS name with certain rules keeping in mind. Here are those rules that SAS needs to follow, when it changes the DBMS column name to valid SAS name. Only 32 mixed case (lower or uppercase) characters are allowed in each variable. Names should be starting with an underscore or an alphabet (either uppercase or lower case character). Invalid characters in the DBMS column (ex. $) should be changed to underscores. See the SAS Language Reference: Dictionary to get more details about the rules. VALIDVARNAME=UPCASE When we mention options VALIDVARNAME=UPPERCASE we are telling SAS to change the column...