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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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