Help using Base SAS procedures

Compress

Accepted Solution Solved
Reply
Contributor
Posts: 57
Accepted Solution

Compress

Hi,

In the compress, 'L' modifer adds lowercase letters to the list of characters to be kept or removed, but in the code below the output removes all characters ABCD?

data test;

x='123-4567-8901 B 234-5678-9012 c';

y=compress(x, 'ABCD', 'L');

proc print;

run;

Any suggestion?

SK


Accepted Solutions
Solution
‎08-16-2013 12:35 AM
Super Contributor
Posts: 307

Re: Compress

Posted in reply to Siddharth123

That's because you've asked COMPRESS to remove the letters 'ABCD' (the second argument) AND the third argument ('L') instructs SAS to remove all lowercase letters.

So . . . all of the letters A, B, C, and D are removed as you requested. And, all lowercase letters are removed as you requested.

The result is the series of numbers, with the sample string you used.

View solution in original post


All Replies
Solution
‎08-16-2013 12:35 AM
Super Contributor
Posts: 307

Re: Compress

Posted in reply to Siddharth123

That's because you've asked COMPRESS to remove the letters 'ABCD' (the second argument) AND the third argument ('L') instructs SAS to remove all lowercase letters.

So . . . all of the letters A, B, C, and D are removed as you requested. And, all lowercase letters are removed as you requested.

The result is the series of numbers, with the sample string you used.

Trusted Advisor
Posts: 1,137

Re: Compress

Posted in reply to Siddharth123

As per the code, in the compress function used compress(x, 'ABCD', 'L'), we are suggesting compress to remove "ABCD" and any lower case letters, so even though the ABCD are all in caps, since we have mentioned them in compress function they are getting removed,

in case you wish to remove only the lower case letters then try

compress(x,, 'L'), this will remove only the lower case letters

the output will be

123-4567-8901 B 234-5678-9012

/*code*/

data test;

x='123-4567-8901 B 234-5678-9012 c';

y=compress(x,,'L');

proc print;

run;

Thanks,

Jagadish

Thanks,
Jag
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 215 views
  • 0 likes
  • 3 in conversation