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

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
  • 3 replies
  • 1183 views
  • 1 like
  • 4 in conversation