Desktop productivity for business analysts and programmers

Renaming attributes in a user friendly manner

Reply
Occasional Contributor
Posts: 10

Renaming attributes in a user friendly manner

Hi there,

I merge some tables using SAS Enterprise Guide. Afterwards I create a report based on this merged data set. Is there any chance to change the database names of the attributes to a user friendly name, meaning using spaces and variable names with a length greater than 32 characters?

If this is possible, can I write a program in EG which renames all variables based on a csv-List (looking for example like: "databaseAttributeName;New Name With Special characters" ).

Thank you very much in advance for your answers

Best Regards

Super User
Posts: 19,145

Re: Renaming attributes in a user friendly manner

Why not use labels for your variables instead?

label my_variable = 'Clean Variable Name';

Contributor
Posts: 66

Re: Renaming attributes in a user friendly manner

SAS variable names cannot have embedded spaces or special characters. Labels are for this, as Reeza already stated. Once you define labels, the dataset can be viewed with labels and reports can be created/printed using labels rather than variable names using "label" option in a procedure call (e.g. proc print).

Occasional Contributor
Posts: 10

Re: Renaming attributes in a user friendly manner


Hi there,

thanks for your answers and sorry for coming back to you so late. I am trying the following script:

proc import datafile="c:\columnsdescriptions.xls"
   dbms=excel
   out=work.labels replace;
getnames=yes;
run;


*filename gencode temp;
filename gencode 'C:\gencode.sas';

data _null_;
set work.labels end=eof;
file gencode;

if _n_=1 then do;
  put "proc datasets lib=LIB nolist;"/
   "modify DEMO_CUSTOMERS;";
end;

put ' label ' variable ' = "' label '";';
if eof then put "quit;";
run;

*error occurs here:

%include gencode;
filename gencode clear;

this throws the error:  ERROR: The HEADER/VARIABLE UPDATE function is not supported by the ODBC engine.

I don't understand this error message, as I am just trying to change the internal label and not a column name in the database. Any ideas on how to solve that?

Best regards

Contributor
Posts: 66

Re: Renaming attributes in a user friendly manner

What is your LIB library? Is it defined using the ODBC engine?

Perhaps it has something to do with the problem reported in this SAS note for Access to Oracle:

SAS/ACCESS® software's LIBNAME engines support creating tables as well as reading from and writing to tables, but they do not support table altering.

http://support.sas.com/kb/37/015.html

Ask a Question
Discussion stats
  • 4 replies
  • 319 views
  • 6 likes
  • 3 in conversation