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!).
Use the ALTER TABLE statement :
proc sql;
alter table myTable modify myColumn label="This is my label";
quit;
PG
Question, I've heard that alter table statement still essentially recreates the table, is this true?
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
If you mean to change the actual label of a dataset, no, you can't do that with SQL. - PG
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...?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.