I am trying to rename a column after transposing my data, but it wont let me... I keep getting a reference error...anyone know what I'm doing wrong? I ran proc contents and it looks like the variable name Is correct
data YieldsRenamed2 (rename=(_label_=cusip));
set Yieldstransposed;
run;
Looking to rename a variable and remove a column but I keep getting an error that says the variable has not been reference...here is my code
data YieldsRenamed (rename= (label_of_former_variable=cusip));
set Yieldstransposed;
run;
this wont rename it and where should I add in the remove argument?
Seems as if you are using the LABEL of a variable instead of the NAME of the variable.
(rename= (label_of_former_variable=cusip))
You might want to run PROC CONTENTS on this data set Yieldstransposed so you can see the actual name of the variable.
can you walk me through how to run proc contents?
@NickA1 wrote:
Looking to rename a variable and remove a column but I keep getting an error that says the variable has not been reference...here is my code
data YieldsRenamed (rename= (label_of_former_variable=cusip));
set Yieldstransposed;
run;
this wont rename it and where should I add in the remove argument?
DROP on either input set or output set as dataset option or a DROP statement in the body of the data step code to "remove" a variable. One way:
data YieldsRenamed (rename= (name_of_variable_to_rename=cusip)); set Yieldstransposed (drop=name_of_variable_to_drop); run;
When to drop depends of when you want to use it. if you need it in the data step then either the drop statement or data set option on the output set. Otherwise it is a style choice.
the variable is called "_label_" but this still didn't work when I tried to rename it
data YieldsRenamed2 (rename=(_label_=cusip));
set Yieldstransposed;
run;
no but another data set has a variable named cusip. I want to merge these two variables. is it possible to do it without making them the same name?
data YieldsRenamed (rename= (label_of_former_variable=cusip)); set Yieldstransposed; run;
You are renaming in Output Data set. Do you want to RENAME label_of_former_variable in the Input Data set, Yieldstransposed ?
data YieldsRenamed; set Yieldstransposed; rename label_of_former_variable=cusip; run;
Use rename this way in input data set.
@KachiM wrote:
data YieldsRenamed (rename= (label_of_former_variable=cusip)); set Yieldstransposed; run;You are renaming in Output Data set. Do you want to RENAME label_of_former_variable in the Input Data set, Yieldstransposed ?
I really doubt if you have a variable named LABEL_OF_FORMER_VARIABLE. You might have a variable named _LABEL_ that has a label of 'LABEL OF FORMER VARIABLE'.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.