BookmarkSubscribeRSS Feed
veeresh10
Calcite | Level 5

Hi Team, 

In old code "C" modifier used in compress function please find code example below. 

data files;
length f_name $200;
infile retail;
input;
f_name=retail;
uname=compress(compress(upcase(f_name),,'c'),' ');
run;

 

Question: What is the use of "C" modifier in compress function and it would be helpful if anybudy explain with brief examples. 
I tried to refer many sites and docs but no budy explained about "C" modifiers. 

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

According to the Compress Function Doc, The 'C' modifier

 

adds control characters to the list of characters.

 

You can see examples of control characters here.

 

Since your data source is an external file, I assume that the file can contain control characters, that need to be removed. No need for two nested Compress Function calls though.

Kurt_Bremser
Super User

The documentation will tell you everything you need to know (Maxim 1).

 

As a quick example, run this:

data test;
length c1 c2 c3 $8;
c1 = "X" !! "0d0a09"x !! "Y";
c2 = compress(c1," ","c");
c3 = compress(c1," ","kc");
put c2= $hex16. c3= $hex16.;
run;

and study the log (Maxim 2).

 

PS

0D = carriage return

0A = linefeed

09 = tab

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 628 views
  • 1 like
  • 4 in conversation