SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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