SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
Nlr
Calcite | Level 5 Nlr
Calcite | Level 5
Hi!

How do you write the 'length' statement in the expression builder? Can it be used when you have a character column?
2 REPLIES 2
ChrisHemedinger
Community Manager
Are you trying to calculate the length of the character value? If so, you can use an expression like this in your calculated column:

LENGTHC( )

For example, if you want to calculate the length of each Name value in SASHELP.CLASS, use this:

LENGTHC(Name)

If you want to make sure that trailing blanks aren't counted, use this:

LENGTHC(TRIM(Name))

Chris
Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
ChrisNZ
Tourmaline | Level 20

If I understand the question correctly, you can either force the length with a put statement:

put( scan(VAR,1), $32.)

or (possibly; untested) add the length after the expression

scan(VAR,1)   length = 32

 

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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