What is Compress function do in SAS?

Reply
Occasional Contributor
Posts: 8

What is Compress function do in SAS?

Hi Everyone,

I am not an SAS User.

I am coding SAS code to T-SQL(SQL Coding) and I came across compress function in SAS which I am unable to understand so if anyone can explain me that then I will be thankful.

customer_name=compress(customer_name,'".,');

contract_description=compress(contract_description,'.,');

   contract_description=left(tranwrd(contract_description,'F20020',''));

contract_description=left(tranwrd(contract_description,'GAT ',''));

contract_description=left(tranwrd(contract_description,'BELTS',''));

contract_description=left(tranwrd(contract_description,'REBATES',''));


Here I am unable to understand that what is happening using compress, tranwrd.


Thanks in Advance.


Thanks

Henary

Occasional Contributor
Posts: 8

Re: What is Compress function do in SAS?

Arthur thanks for quick reply.

I found the same links when I searched in google.

All I am interested is below two queries...

customer_name=compress(customer_name,'".,');

contract_description=compress(contract_description,'.,');


I mean I am unable to understand this two queries.

As per Query1 my understanding is that compress will replace or modify customer_name column but it is replacing what with what is big headache for me...


Query 2 I am not able to understand completely...


If you or some1 else can let me know then it will be helpful...


Thanks in Advance..


Henary

Super User
Super User
Posts: 7,039

Re: What is Compress function do in SAS?

Returns a character string with specified characters removed from the original string.

In these cases the "original string" and the target of the assignment statement are the same variable. So they are being used to strip the specified characters from the variables. Note these statements also demonstrate two of the ways to pass a string value to a function.  Either using the name of a character variable or using a literal string inside of quotes.

customer_name=compress(customer_name,'".,');

Will remove double quotes, periods and commas from the variable CUSTOMER_NAME.

contract_description=compress(contract_description,'.,');

Will remove periods and commas from CONTRACT_DESCRIPTION.


Occasional Contributor
Posts: 8

Re: What is Compress function do in SAS?

Thanks Tom...

This is what I was looking for..

Thanks again..

Henary

Ask a Question
Discussion stats
  • 4 replies
  • 339 views
  • 3 likes
  • 3 in conversation