BookmarkSubscribeRSS Feed
jcis7
Pyrite | Level 9

I used the following code to rename a variable.  Why original name come up under 'Label' when using Proc Contents (i.e., variable name becomes uncon and Label is allreq.

What is a label used for?

data rename;


     set orig; 


     rename  allreq=uncon;

run;

Thanks!

5 REPLIES 5
Reeza
Super User

because the label isn't the variable name automatically. You need to change it as well. 

Variable names and labels aren't tied to the same thing, which is nice in some circumstances and annoying in others.

data rename;

     set orig;

     label allreq='uncon';

     rename allreq=uncon;

run;

RichardinOz
Quartz | Level 8

If you do not explicitly set the variable label, then the variable name is used.  So in that case whern the variable is renamed, the label should change.  However, when you explicitly set the label for the variable (using a label statement) it is unchanged by a rename.

Richard

jcis7
Pyrite | Level 9

Thanks everyone!  Suggestions on resources to learn more about utility of labels?

Reeza
Super User

3 things to know:

1. attrib _all_ label=''; removes all labels

2. vlabel will get the name of the label

3. label var="my_label" sets a label

They're not very complex. I wish there was a way to set labels more easily, but that's about it.

You can always search google : variable label site:lexjansen.com to see what else there is.

Good luck.

jcis7
Pyrite | Level 9

Thanks so very much!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 18991 views
  • 0 likes
  • 3 in conversation