BookmarkSubscribeRSS Feed
awesome_opossum
Obsidian | Level 7

I understand the native character limit for variable names in SAS is 32. I would like to change it to 30. 

 

Is there any easy way to do this? 

4 REPLIES 4
ChrisHemedinger
Community Manager

The VALIDVARNAME option can enforce certain pre-defined standards. As you know, the max length is 32 bytes. There isn't an option to set this to 30.

  • VALIDVARNAME=V7 (the default) is 32-byte max, alphanumeric with no spaces/special chars
  • VALIDVARNAME=ANY allows 32-byte max, but could have special chars/spaces using the literal notation to address them (ex 'my var name'n)
  • VALIDVARNAME=V6 enforces an 8-byte max. Hello 1985: your variables are calling.
  • VALIDVARNAME=UPCASE - same as V7 but enforces uppercase style.

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Tom
Super User Tom
Super User

@awesome_opossum wrote:

I understand the native character limit for variable names in SAS is 32. I would like to change it to 30. 

 

Is there any easy way to do this? 


No. 

You can use the option VALIDVARNAME=V6 to force it to use 8 as the limit.

 

Why not just run your own tests to flag any variable with a longer name.

Perhaps something like:

proc sql;
create table longnames as
select libname,memname,name
  from dictionary.columns
  where length(name) > 30
;
quit;
awesome_opossum
Obsidian | Level 7
Thanks, this is a good answer. My concern is a matter of interfacing with a database that has a 30 limit and preventing issues with exchange between systems. It seems manually checking may be the only option, then, and that is an elegant approach.
Tom
Super User Tom
Super User

@awesome_opossum wrote:
Thanks, this is a good answer. My concern is a matter of interfacing with a database that has a 30 limit and preventing issues with exchange between systems. It seems manually checking may be the only option, then, and that is an elegant approach.

If you just get in the habit of using reasonable variable names you should never come close to using names that are anywhere near 30 bytes long.  You can use the LABEL feature of SAS to attach longer descriptions of the variables.

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
  • 4 replies
  • 2980 views
  • 3 likes
  • 3 in conversation