BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Siddharth123
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Fugue
Quartz | Level 8

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

2 REPLIES 2
Fugue
Quartz | Level 8

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.

Jagadishkatam
Amethyst | Level 16

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 947 views
  • 0 likes
  • 3 in conversation