BookmarkSubscribeRSS Feed
BarryP
Quartz | Level 8

Hi,

I ran into a problem that took a long time to debug.  I renamed a variable so that it would contain spaces when displayed in SASVA.  I know that there are other ways to do this, but I needed to keep the variable names consistent with data that was previously uploaded in Excel.

This does not seem to happen all the time (though I could be wrong).  I would just like to understand when I can expect this to happen and why.


Data New_Table;

Set Old_Table;

Rename Variable_Name = 'Variable Name'n;

Run;




Results:  Appears as Variable Name in my output, but when I hover over the column header, it shows that I have a label that is Variable_Name.

When this goes to SASVA, it appears as Variable_Name but when I hover over (or maybe right click) it lists the source variable as Variable Name.



FWIW, I fixed it by creating a new variable, making it = to the old variable, and then dropping the old variable.


Thanks!

2 REPLIES 2
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

if you do not create a label for a variable SAS deflates to naming the labels with the variable name.

when you rename a variable only the variable name is changed and the old label is inherited.

to get what you are expecting use a label statement to label that variable to what you want it to display.

 

Tom
Super User Tom
Super User

Why would SAS change the label if all you did was change the name?

You could set the new label.

data New_Table;
  set Old_Table;
  rename Variable_Name = 'Variable Name'n;
  label Variable_Name = 'Variable Name';
run;

Or perhaps just remove the old one.

data New_Table;
  set Old_Table;
  rename Variable_Name = 'Variable Name'n;
  label Variable_Name = ' ';
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 1296 views
  • 0 likes
  • 3 in conversation