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

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: 3,895

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;

Ask a Question
Discussion stats
  • 5 replies
  • 11889 views
  • 1 like
  • 4 in conversation