- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
can you walk me through how to run proc contents?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In the documentation for each procedure, there's an examples section that includes code that shows you how to use the procedure.
https://documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=n1a5k5u51pvnlhn17j9v82nc...
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data YieldsRenamed; set Yieldstransposed; rename label_of_former_variable=cusip; run;
Use rename this way in input data set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content