Some tips on asking a question. Whilst providing a descriptive title is great, providing some text in the post should also be done. Provide example test data, in the form of a dataset, what you have tried, and what the output should look like. At a guess:
data a; a=1; b=2; label a="abcd"; label b="ADer"; run; data _null_; set sashelp.vcolumn (where=(libname="WORK" and memname="A")) end=last; if _n_=1 then call execute('proc datasets library=work noprint; modify a;'); call execute (cat(' attrib ',strip(name),' label="',strip(upcase(label)),'";')); if last then call execute('run; quit;'); run;
It would be very helpful if you just copy/pasted the message(s) and the preceding code from the log into a {i} window.
Then you need to break up the code into by groups, this is why posting test data/required output is helpful, we don't have to guess:
data a; a=1; b=2; label a="abcd"; label b="ADer"; run; data b; a=1; b=2; label a="abcd"; label b="ADer"; run; data _null_; set sashelp.vcolumn (where=(libname="WORK" and memname in ("A","B"))); by memname; if first.memname then call execute(cat('proc datasets library=work noprint; modify ',strip(memname),';')); call execute (cat(' attrib ',strip(name),' label="',strip(upcase(label)),'";')); if last.memname then call execute('run; quit;'); run;
@SrikanthY wrote:
I wanted to change only variable names that to for multiple data sets.
I have changed it for my convenience, but its displaying warning messages
on log. below is my code.
data _null_;
set sashelp.vcolumn (where=(libname="WORK" and memname in ("ADOMSG"
"AIR"))) end=last;
if _n_=1 then call execute(catx(" ",'proc datasets library=work nolist;
modify',memname,';'));
call execute (cat(' attrib ','name="',strip(lowcase(name)),'"
label="',strip(upcase(label)),'";'));;
if last then call execute('run; quit;');
run;
[image: Inline image 1]
##- Please type your reply above this line. Simple formatting, no
attachments. -##
That first line should have been in your first post.
Images aren't attached when responding via email as noted - simple formatting, no attachments. You need to specifically upload your images to the forum.
Is this just for presentation purposes? SAS isn't case sensitive when referring to variable names.
I think the issue somehow is valid.
You could have decided for a specific notation, that includes casing - usually for better "readability".
I don't have SAS at my fingertips right now, but I recall that I've tried to change the case of a variable/data set name, but if all the letter where the same, it didn't take effect. Or...?
@LinusH wrote:
I think the issue somehow is valid.
You could have decided for a specific notation, that includes casing - usually for better "readability".
I don't have SAS at my fingertips right now, but I recall that I've tried to change the case of a variable/data set name, but if all the letter where the same, it didn't take effect. Or...?
It works with PROC DATASETS or the RENAME data set option but not the RENAME statement.
data class;
set sashelp.class;*(rename=(Name=NaMe));
rename name=NaMe;
run;
proc print;
run;
proc datasets lib=work;
modify class;
rename Name=name;
run;
proc print;
run;
data a; a=1; b=2; label a="abcd"; label b="ADer"; run; data b; a=1; b=2; label a="abcd"; label b="ADer"; run; data _null_; set sashelp.vcolumn (where=(lowcase(name)='a')) end=last; call execute(cat('proc datasets library=',libname,' nolist nodetails;')); call execute(cat('modify ',memname,'; rename ',name,'=new_',name,';quit;')); run;
It depends on your OS, maybe you can't do it.
options validvarname=upcase;
data class;
set sashelp.class;
run;
Oh, not label, variable name. In which case why? It matters not to programming if they are upper/lower/mixed case. If you have an output spec to match to then I would suggest creating an emtpy table which matches your spec, then setting your data to that spec. This has the benefits of having a fixed structure, and you can pull out any problems:
proc sql; create table MYOUT ( VAR1 char(200), VAR2 num ); quit; data myout; set myout processed data; run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.