BookmarkSubscribeRSS Feed
LearnByMistk
Obsidian | Level 7

I have column name as age_10+, how would I rename that var in sas as it's already been imported  via teradata connection. Any help is really appreciated .

6 REPLIES 6
LearnByMistk
Obsidian | Level 7
data a;
rename age_10+=age_10_p;
set b;
run;
Tom
Super User Tom
Super User

Did the "import" already run successfully?  What is the name used for the variable in the resulting SAS dataset.  Use PROC CONTENTS or other way of looking at the actual name. Don't just look at what you see in some viewer or PROC output as that might be displaying the label.

 

If you have the SAS option VALIDVARNAME set to ANY then you can use a Name Literal to reference that goofy name.  So if your SAS dataset is named WORK.MYDATA then you could rename the variable this way.

proc datasets lib=WORK nolist;
modify MYDATA ;
  rename 'age_10+'n=age_10plus ;
run;
quit;

If you have VALIDVARNAME=V7 then the name was probably already fixed by replacing invalid bytes with underscores.  So most likely it is named AGE_10_ 

LearnByMistk
Obsidian | Level 7
options VALIDVARNAME=V7 ;
data a;
29 rename AGE_85_+_PCT=age_85_plus;
ERROR: Missing numeric suffix on a numbered variable list (AGE_85_-_PCT).
ERROR: Old and new variable name specifications for RENAME must be of the same type. Statement is ignored.
ERROR 22-322: Syntax error, expecting one of the following: -, :, =.

ERROR 200-322: The symbol is not recognized and will be ignored.
SASKiwi
PROC Star

VALIDVARNAME is only relevant when importing data into SAS. Once your non-standard variable names are in SAS then you have to reference them as name literals as already explained.

ChrisNZ
Tourmaline | Level 20

29 rename AGE_85_+_PCT=age_85_plus;
ERROR: Missing numeric suffix on a numbered variable list (AGE_85_-_PCT).

This code is not what was provided to you as a solution.

You have to enclose the variable name inside     '  'n     as shown.

 

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 2923 views
  • 2 likes
  • 5 in conversation