- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 01-19-2021 02:24 AM
(910 views)
proc sql;
alter table students rename column Sex to Gender;
quit;
here it shows error
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What does the error say? Are you sure you want to rename the variables like this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;