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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 591 views
  • 0 likes
  • 4 in conversation