Language Reference

TABLERENAMEVAR Call

CALL TABLERENAMEVAR (table, cols, newNames) ;

This subroutine is supported by the IML procedure and the iml action.

The TableRenameVar subroutine changes the names of specified columns. The subroutine takes the following input arguments:

table

specifies an existing table.

cols

specifies the columns of the table. The cols argument can be a numeric vector of column numbers (such as {2 4 7}) or a character vector of names (such as {"X" "Y"}).

newNames

specifies a character vector of valid SAS variable names, which will become the new names for the specified columns.

The following statements rename the Sex and Height variables of the Sashelp.Class data. Figure 466 shows the original and the new names for the columns.

tbl = TableCreateFromDataSet("Sashelp", "Class");
oldNames = TableGetVarName(tbl);
call TableRenameVar(tbl, {"Sex" "Height"},  /* old names */
                         {"Gender" "Hgt"}); /* new names */
newNames = TableGetVarName(tbl);
print (oldNames // newNames)[rowname={"Old" "New"}];

Figure 466: Old and New Column Names

OldNameSexAgeHeightWeight
NewNameGenderAgeHgtWeight


Last updated: May 07, 2026