@MK_96 wrote: HOW CAN I EXTRACT ONLY "Y" VALUES TO NEW VARIABLE FROM BELOW CODE .? IS THERE ANY FUNCTION THAT WORKS ?? DATA CHK; TEXT="122 AGH Y yy jaja Yy &#^#7aa "; RUN;
There are probably multiple functions that work depend on what the desired result actually is.
If you want to remove the Y, first you have tell us if that means remove the lower case y as well. I say this because you are using all capital letters so it is not clear.
Here are just some of the possible examples
DATA CHK;
TEXT="122 AGH Y yy jaja Yy &#^#7aa ";
text2 = compress(text,'Y');
text3 = compress(text,'y');
text4 = compress(text,'Y','i');
text5 = compress(text,'Y','ik');
text6 = translate(text,' ','Yy');
RUN;
Compress removes characters. Examples show just upper case Y, lower case Y, case insensitive Y, remove everything except the case insensitive Y's (extracted from the string and KEPT). Translate replaces characters with a different single character.
TRANWRD might be another option as well as regular expressions.
But since you did not provide an example of what you expect this is all guesses as to what you may want.
... View more