BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
xyxu
Quartz | Level 8

My code returns unexpected result as follows:

x = index(lowcase(security_name), lowcase("alltel communications"));
x2 = index(lowcase(security_name), lowcase(name_holding_clean));

xyxu_0-1589208329247.png

Shouldn't x=x2? My guess is that it's related to the length of name_holding_clean, but not sure how to deal with it.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Most of the functions such as LOWCASE when used as a parameter to another function return the result  padded with blanks to length of the variable.

Try

 

x2 = index(lowcase(security_name), strip( lowcase(name_holding_clean) ) );

 

View solution in original post

5 REPLIES 5
ballardw
Super User

Most of the functions such as LOWCASE when used as a parameter to another function return the result  padded with blanks to length of the variable.

Try

 

x2 = index(lowcase(security_name), strip( lowcase(name_holding_clean) ) );

 

xyxu
Quartz | Level 8

You are right, thanks!

Why LOWCASE does not pad with blanks when the I copy the string, instead of using a variable as input?

Tom
Super User Tom
Super User

Note that the LOWCASE() function calls has nothing to do with this issue.

 

SAS stores character variables as fixed length.   If you assign a value that is shorter than the max then it is padded with spaces. If you assign a value that is longer it is truncated.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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