BookmarkSubscribeRSS Feed
jeremy7
Calcite | Level 5

Hi,

How can I select column name with _ and space like name _category.

 

Is there any way in SAS that can standardize the column name ? 

2 REPLIES 2
Tom
Super User Tom
Super User

@jeremy7 wrote:

Hi,

How can I select column name with _ and space like name _category.

 

Is there any way in SAS that can standardize the column name ? 


To reference a name that does not follow normal rules you have to use a name literal 

'name _category'n

What is the SOURCE of the data that has names with spaces in them?

To allow SAS to use such names you have to have set the VALIDVARNAME option to ANY.

If the source was an Excel file or text file that you imported you could set the VALIDVARNAME back to V7 and then re-import the data.  PROC IMPORT should then convert those invalid names to something usable.  Perhaps name__category.

Reeza
Super User

Add this to the top of your code and re-run it.

options validvarname=v7;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 779 views
  • 1 like
  • 3 in conversation