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

Hello,

 

I am completely new to SAS and I am trying to make sense of the following piece of code.

(PUT(TRIM(BFT_TYPE_CODE_VALUE), $CNBS_bft_type.)) as BFT_TYPE_DESCRIPTION

length = 200

format = $200

informat = $200

label = 'BFT_TYPE_DESCRIPTION'

 

It is the code in brackets that I am trying to understand.

 

Can somebody explain in English what the code is doing?

 

Kind Regards

 

Vinnie

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Hi and welcome to the SAS communities 🙂

 

This looks like something from a PROC SQL step.. The code in the brackets

 

 

(PUT(TRIM(BFT_TYPE_CODE_VALUE), $CNBS_bft_type.)) as BFT_TYPE_DESCRIPTION

Working our way from the inside out.. The Trim Function removes trailing blanks from the character variable BFT_TYPE_CODE_VALUE. Next, the PUT FUNCTION is used to return the value of the trimmed variable in the format specified by $CNBS_bft_type. This value is assigned to the new variable BFT_TYPE_DESCRIPTION.

 

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Hi and welcome to the SAS communities 🙂

 

This looks like something from a PROC SQL step.. The code in the brackets

 

 

(PUT(TRIM(BFT_TYPE_CODE_VALUE), $CNBS_bft_type.)) as BFT_TYPE_DESCRIPTION

Working our way from the inside out.. The Trim Function removes trailing blanks from the character variable BFT_TYPE_CODE_VALUE. Next, the PUT FUNCTION is used to return the value of the trimmed variable in the format specified by $CNBS_bft_type. This value is assigned to the new variable BFT_TYPE_DESCRIPTION.

 

BigVinnie
Calcite | Level 5
Thank you
Kurt_Bremser
Super User

@BigVinnie wrote:

Hello,

 

I am completely new to SAS and I am trying to make sense of the following piece of code.

(PUT(TRIM(BFT_TYPE_CODE_VALUE), $CNBS_bft_type.)) as BFT_TYPE_DESCRIPTION

length = 200

format = $200

informat = $200

label = 'BFT_TYPE_DESCRIPTION'

 

It is the code in brackets that I am trying to understand.

 

Can somebody explain in English what the code is doing?

 

Kind Regards

 

Vinnie


Here, you are not using the put statement, but the put function in an SQL select.

The put() function takes the first argument and formats it with the format supplied as the second argument, and delivers the result as a character string.

The trim() function used to prepare the first argument to put() simply removes trailing blanks from a string.

 

The documentation for SAS data step functions (which can also be used in SAS SQL) is found here (so you can follow Maxim 1).

BigVinnie
Calcite | Level 5

Thank you for your help.

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

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1288 views
  • 0 likes
  • 3 in conversation