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

I'm trying to remove the trailing spaces with the use Strip function as follows, but it is not removing the spaces in the final Output.

 

Am I missing something?

 

FNCTL_CMPNT_NM=strip(ifc(indexw("&etls_jobName","_ADP_"),'AP','LIS'));

My Value for FNCTL_CMPNT_NM is 'LIS                                                                                  ' after the execution of the above code.

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

Hello,

 

Imagine putting a small item in a large drawer. It won't reduce the size of the drawer.

The same happens here : you affect a small string to a previously large dimensioned string

so FNCTL_CMPNT_NM will contain the stripped string and the rest will be filled with blanks.

View solution in original post

2 REPLIES 2
Patrick
Opal | Level 21

I assume the "final output" is what gets into variable FNCTL_CMPNT_NM

With SAS character variables being of type CHAR you will always have strings padded up with blanks up to the length of the character variable so there are in a way always trailing blanks. Nothing you can do about it except to define the variable with a length not longer as you really need it.

gamotte
Rhodochrosite | Level 12

Hello,

 

Imagine putting a small item in a large drawer. It won't reduce the size of the drawer.

The same happens here : you affect a small string to a previously large dimensioned string

so FNCTL_CMPNT_NM will contain the stripped string and the rest will be filled with blanks.

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
  • 2 replies
  • 913 views
  • 3 likes
  • 3 in conversation