Help using Base SAS procedures

Renaming Column during Proc Import

Reply
Contributor
Posts: 65

Renaming Column during Proc Import

Hi,

I am having a big dataset with more than 50+ columns in Excel format. Column names are perfect but bit complicated so I thought of renaming the column name.

Can we rename column during the Proc Import procedure. Or do I need to create new dataset and use rename keyword ?

Please let me know and thanks in advance.
SAS Employee
Posts: 13

Re: Renaming Column during Proc Import

Check this

proc import
datafile="&ExcelFile"
out=ExcelDataSet ( rename=Col1=ColumnOne)
dbms=EXCEL;
DBSASLABEL=NO;
run;
Contributor
Posts: 65

Re: Renaming Column during Proc Import

Posted in reply to DataShare
Hi,

I tried to use the code you provided. But it seems that there is no keyword DBSASLABEL in SAS. Are you refering to the keyword GetNames ?
SAS Employee
Posts: 13

Re: Renaming Column during Proc Import

Are you trying this with DBMS=EXCEL ?
Respected Advisor
Posts: 4,736

Re: Renaming Column during Proc Import

Even though I like coding a lot I would use Enterprise Guide for such a task (if it's a once off job).

The import wizard creates all the code you need and you can also change column names and attributes in one of the steps (think it's step 3).

HTH
Patrick
Contributor
Posts: 37

Re: Renaming Column during Proc Import

[ Edited ]

you can simply use rename option , check this

 

proc import datafile="&file"
out=want(rename=(col11=new_var col22=new_var2))
dbms=xlsx replace;
getnames=yes;
run;

Contributor
Posts: 47

Re: Renaming Column during Proc Import

So it seems like by using the "GETNAMES = YES" option, I was forcing SAS to create silly names that I was unable to reference. I was being silly, an easy work around was to change GETNAMES to NO, and then just rename the columns manually (there were only 26 columns, so it wasn't too bad.

 

Many thanks to everyone for their input.

 

Mike

Ask a Question
Discussion stats
  • 6 replies
  • 17689 views
  • 1 like
  • 5 in conversation