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.

 

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
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.

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!

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
  • 1799 views
  • 3 likes
  • 3 in conversation