Hi all,
I'm trying to compress a data like "<= 0.3" to "0.3", but COMPRESS FUNCTION seems that just can compress ALL punctuation marks at one time...So, is there any better way to compress only "<= " and keep the decimal?
However, this is just one example of my data. I need a resolution for all cases like this. Thank you!
Original Compressed
<= 0.3 0.3
0.58 0.58
> 1.2 1.2
45 45
Well, its likely that you have other maths symbols, so maybe reverse the thinking, the below "k"eeps, only "d"igits and the decimal:
data test; original = "<= 0.3"; compressed = compress(original,'.','kd'); run;
data test;
original = "<= 0.3";
compressed = compress(original,'<=');
run;
proc print data=test;
run;
works.
Output:
Obs original compressed 1 <= 0.3 0.3
Hi @JohnChen_TW;
You can use this line :
compressed = compress(original,'<=');
this will remove <= combination from the variaable;
But, on the third line you provided another special character in sample data,
so below code will not compress this special character;
so in this case you can use this code:
data test;
set test;
compressed=compress(original,'<');
compressed=compress(original,'=');
compressed=compress(original,'>');
run;
it will remove all the possible combination like: <=, <, =, >, => from the variable
Well, its likely that you have other maths symbols, so maybe reverse the thinking, the below "k"eeps, only "d"igits and the decimal:
data test; original = "<= 0.3"; compressed = compress(original,'.','kd'); run;
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: