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.

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1549 views
  • 3 likes
  • 3 in conversation