BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
walterwang
Obsidian | Level 7

I imported a table from Excel. The variable name is "a2-4". How to deal with these names?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Setting the SAS option VALIDVARNAME to V7 will automatically translate variable names to valid SAS names. So a2-4 will be renamed to a2_4. This is actually a good practice to follow as it avoids having to reference non-valid SAS variable names as @Patrick describes: 'a2-4'n

View solution in original post

3 REPLIES 3
Patrick
Opal | Level 21

Depending on how you import there might be options available for SAS to translate source column names into valid SAS variable names. 

If it's not a valid name then you must quote it as a SAS name literal when you use the column in code as done below:

'a2-4'n = 5;
SASKiwi
PROC Star

Setting the SAS option VALIDVARNAME to V7 will automatically translate variable names to valid SAS names. So a2-4 will be renamed to a2_4. This is actually a good practice to follow as it avoids having to reference non-valid SAS variable names as @Patrick describes: 'a2-4'n

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 712 views
  • 0 likes
  • 4 in conversation