The global option nolabel does not just remove the variable label in dictionaries but also the contents of the label variable (dictionary.columns/sashelp.vcolumn and proc contents).
Is there a workaround to avoid this such as another global option I would not be aware of?
data demo;
test=1;
label test='test';
run;
options nolabel;
proc print data=sashelp.vcolumn;
where upcase(libname)='WORK' and
upcase(memname)='DEMO';
var libname memname name label;
run;
If you only want the label for the duration of one proc then turn the option back on:
options label; proc print data=sashelp.vcolumn; where upcase(libname)='WORK' and upcase(memname)='DEMO'; var libname memname name label; run;
You will see that that the label is in the dictionary table.
Note that both the dictionary table reference and the sashelp.vcolumn and other information tables are VIEWS. Which means that they are populated when used. If you have the NOLABEL in effect then the dictionary view is honoring the setting when used.
Personally in 30+ years using SAS I have never had a need to set the NOLABEL option though had some source code provided that had unexpected results because the option was buried in the code.
NOLABEL does not remove labels, it only tells all SAS procedures to ignore them. Since the DICTIONARY tables are created dynamically whenever used, they also honor the setting of the option.
I understand why it happens. The thing is that the user will only search for an explanation when he notices the absence of the variable labels and it can take years sometime to notice it. A logical explanation is not sufficient to avoid daily pitfalls.
That's why the default setting of the option is LABEL. If someone changes that (and does not sufficiently document it), it's not the fault of the SAS system.
Depending on the use-case, perhaps you could create a view of the dataset with the labels removed?
data have;
test=1;
label test='label for test';
run;
options nolabel;
data want_nolabel / view=want_nolabel ;
set have ;
run ;
options label;
proc print data=sashelp.vcolumn;
where upcase(libname)='WORK' and
upcase(memname) IN ("HAVE" "WANT_NOLABEL");
var libname memname name label;
run;
As I don't usually create my own views, I never realized that the global option nolabel also affects the variable labels in the view. Good to know. Thanks
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.