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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1097 views
  • 2 likes
  • 4 in conversation