BookmarkSubscribeRSS Feed
xxformat_com
Barite | Level 11

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;
6 REPLIES 6
ballardw
Super User

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.

 

 

Kurt_Bremser
Super User

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.

xxformat_com
Barite | Level 11

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.

 

 

Quentin
Super User

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;
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
xxformat_com
Barite | Level 11

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

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1483 views
  • 3 likes
  • 4 in conversation