05-15-2013 03:38 PM
Greetings all. I'm having some difficulty renaming a column in proc sql. Consider the following:
create table sometable as
'0' as group_num,
somereallylongcolumnname as short_name
When I run this code, the first column is correctly named, as it should have been based on some documentation I found on the web. However, the column 'somereallylongcolumnname' retains its name eventhough I used an alias. I read where the alias will be displayed on reports and such, but I need the column to be renamed in the dataset. I tried using (rename= at various places, but none seem to work. I'm sure it is something simple, but I just can't get it. Any ideas? Thank you.
05-15-2013 04:03 PM
Seems like you might be confusing column names with column labels. If you are sourcing your data from an external database often the label will be set to the same as the column name. The label is what is often used in reports. You could try the NOLABEL SAS option to avoid assigning labels when importing data.
05-15-2013 04:56 PM
SASKiwi, thank you for the reply. I'm not concerned about the label, its just that is the only way I could get the column to be named as I want. My concern is that I need to use this dataset in some other stuff, and I would like to be able to reference the alias I named in the proc sql statement. It works not, so I'm not sure if it's a label or the column name is correct, but I can reference short_name in the dataset. Thanks.
05-15-2013 04:26 PM
I agree with Kiwi. In your original code you actually DID rename the column, however you were still displaying its label of "somereallylongcolumnname", therefore when you open your dataset this is what you see (you acutally see the label and not the column name in the column header. You can see both if you go to the column properties)!
hope that helps