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...?
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.