Help using Base SAS procedures

changing sas dataset labels using PROC SQL

Reply
Contributor
Posts: 53

changing sas dataset labels using PROC SQL

data
Hi, I know it is possible to change EXISTING sas dataset labels using PROC DATASETS, but I am wondering if a smiliar capability exists using PROC SQL. I realize that you can CREATE a sas dataset with a label. Thanks in advance. Please supply syntax with answer (if there is one!).

Respected Advisor
Posts: 4,934

Re: changing sas dataset labels using PROC SQL

Use the ALTER TABLE statement :

proc sql;

alter table myTable modify myColumn label="This is my label";

quit;

PG

PG
Super User
Posts: 19,869

Re: changing sas dataset labels using PROC SQL

Question, I've heard that alter table statement still essentially recreates the table, is this true?

Respected Advisor
Posts: 4,934

Re: changing sas dataset labels using PROC SQL

Maybe not for a simple operation like a change of label. In a little test I just ran, the modify time of my dataset is two minutes later than the create time... For that to happen, SAS would have to set the create time of the new copy of the dataset to the create time of the old copy. Possible, but unlikely.

PG

PG
Respected Advisor
Posts: 4,934

Re: changing sas dataset labels using PROC SQL

If you mean to change the actual label of a dataset, no, you can't do that with SQL. - PG

PG
Super User
Posts: 5,438

Re: changing sas dataset labels using PROC SQL

I don't think haves a wish, more of a concern...?

Did some tests as well. My conclusion is when you change table metadata that only resides in the header of the file, the table isn't recreated. This goes for labels, formats and informats.

Other changes that changes the structure of the data part of the file will force a recreation of the table. This will include operations such as changing columns length, column type (not available in alter table), adding or dropping columns.

When we are at it, for it would seem naturally to have the opportunity to change columns names using alter table. The doc says this can be done using the rename= ds option. But I haven't seen any examples on how to us this together with alter table. My guess that this suggestion has to be used together with create table, or am I missing something obvious...?

Data never sleeps
Ask a Question
Discussion stats
  • 5 replies
  • 4213 views
  • 1 like
  • 4 in conversation