Multiple choice technology programming languages

data test ; x="Math A English B Physics A"; y=compress(x,'ABCD','k'); put y; run; The value of 'y' written in log is :

  1. ABA

  2. Math A English B Physics A

  3. a A B A

  4. aABA

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The COMPRESS function with modifier 'k' KEEPS only the specified characters (removes all others). With third argument 'ABCD' and 'k', it retains only A, B, C, D (case-sensitive) from the source. In 'Math A English B Physics A', keeping only 'ABCD' yields 'A B A' → 'ABA' after compression of the remaining blanks between kept characters. The function removes all other letters and spaces, leaving only the specified characters.