BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
proc sql;
alter table students rename column  Sex to Gender;
quit;

here it shows error

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

What does the error say? Are you sure you want to rename the variables like this?

Kurt_Bremser
Super User

Maxim 1: Read the Documentation.

ALTER TABLE in SQL. There is no RENAME clause for this SQL statement.

To rename columns, use the RENAME statement or the RENAME= dataset option in data steps, or do a SELECT with AS in SQL.

Shmuel
Garnet | Level 18

If you don't want to rewrite he dataset with the new column name, but do it inplace - you can use

proc datasets lib=<librray> nolist;
   modify <dataset name>;
     rename <current name> = <new name>;
quit;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1204 views
  • 2 likes
  • 4 in conversation