BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
whymath
Barite | Level 11

According to SAS Help Center, vlabel function returns the label that is associated with that variable name, or the variable name if no label exists.

 

Is it possible to make vlabel return missing value when no label exists?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Parse the result and if the same as the variable then set to missing would be the only approach I am aware of. 

 

However, when you have a label like "Name" for a variable with the name of 'Name' you are going to cause problems. 

 

You can get a missing value for the label by examining sashelp.vcolumn, or dictionary.columns or an output data set created with Proc Contents. If a label is not assigned the Label variable would be missing in the resulting data set.

Example looking at the SAS supplied data set SASHELP.CLASS that you should have installed:

Proc contents data=sashelp.class out=work.classinfo;
run;

Or

data work.classinfo2;
   set sashelp.vcolumn (where=(libname='SASHELP' and memname='CLASS'));
run;

Or

proc sql;
   create table work.classinfo3 as
   select *
   from dictionary.columns
        where libname='SASHELP' and memname='CLASS'
   ;
quit;

Note that the Proc Contents data set has a different structure and content than the the other two.

If using the SASHELP.VCOLUMN or dictionary table the Libname  and Memname, library and data set names, must use upper case values from the source as that is how they are stored. The view holding, SASHELP.VCOLUMN holds information of every variable in every data set in your current session and if you don't provide the library and member name you will get a lot of unwanted stuff.

View solution in original post

1 REPLY 1
ballardw
Super User

Parse the result and if the same as the variable then set to missing would be the only approach I am aware of. 

 

However, when you have a label like "Name" for a variable with the name of 'Name' you are going to cause problems. 

 

You can get a missing value for the label by examining sashelp.vcolumn, or dictionary.columns or an output data set created with Proc Contents. If a label is not assigned the Label variable would be missing in the resulting data set.

Example looking at the SAS supplied data set SASHELP.CLASS that you should have installed:

Proc contents data=sashelp.class out=work.classinfo;
run;

Or

data work.classinfo2;
   set sashelp.vcolumn (where=(libname='SASHELP' and memname='CLASS'));
run;

Or

proc sql;
   create table work.classinfo3 as
   select *
   from dictionary.columns
        where libname='SASHELP' and memname='CLASS'
   ;
quit;

Note that the Proc Contents data set has a different structure and content than the the other two.

If using the SASHELP.VCOLUMN or dictionary table the Libname  and Memname, library and data set names, must use upper case values from the source as that is how they are stored. The view holding, SASHELP.VCOLUMN holds information of every variable in every data set in your current session and if you don't provide the library and member name you will get a lot of unwanted stuff.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 236 views
  • 2 likes
  • 2 in conversation