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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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