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;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.