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.
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.
Adds all controll characters to the compress function (e.g. carriage return).
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
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!
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.