BookmarkSubscribeRSS Feed
frisco
Calcite | Level 5

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!).

5 REPLIES 5
PGStats
Opal | Level 21

Use the ALTER TABLE statement :

proc sql;

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

quit;

PG

PG
Reeza
Super User

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

PGStats
Opal | Level 21

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
PGStats
Opal | Level 21

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

PG
LinusH
Tourmaline | Level 20

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 15528 views
  • 1 like
  • 4 in conversation