Could someone please remind me what !! means in SAS programming? I was viewing this page below where someone had offered an example that uses strip() followed by !!
I remember learning this a few years ago, but I can't recall now what the double exclamation does when used after the strip function. Thanks!!
Solved: SAS strip function doesn't work - SAS Support Communities
data test;
char=strip('ALTEPLASE INJECTION 2 MG ') !! 'Extra text';
run;
Two exclamation marks are one method to write the simple concatenation operator.
Two exclamation marks are one method to write the simple concatenation operator.
Thanks again, Kurt. I knew I'd seen them, but I couldn't think where. These days I always use CAT(), CATS() etc, so I'd forgotten about !! that was used before the introduction of the new concatenation functions.
@Buzzy_Bee wrote:
Could someone please remind me what !! means in SAS programming? I was viewing this page below where someone had offered an example that uses strip() followed by !!
I remember learning this a few years ago, but I can't recall now what the double exclamation does when used after the strip function. Thanks!!
Solved: SAS strip function doesn't work - SAS Support Communities
data test; char=strip('ALTEPLASE INJECTION 2 MG ') !! 'Extra text'; run;
Older keyboards/ text displays didn't support the | character. So ! is used instead.
Some people copy or use intentionally.
the above might be better done as
data test; char=catx(' ','ALTEPLASE INJECTION 2 MG', 'Extra text'); run;
The CATX function will place the text in the first position, in this case a single space, between all the other parameters (could be variables, expressions or literal text as above) and strips all of the other parameters.
Thank you, Balladw. That is indeed how I would have written that line of code (I use the new CAT() functions, such as the CATX() function that you suggested). Originally at university I was taught the pipe symbol (|) that you mentioned, prior to the introduction of the CAT() functions in SAS, but the exclamation is certainly the rarer symbol that I don't often see.
I read once that it is considered to be an outdated SAS programming style to still use symbols instead of the CAT() functions. Does anyone have an opinion on that? I think SAS courses these days only teach the CAT() functions now from what I've seen.
@Buzzy_Bee wrote:
Thank you, Balladw. That is indeed how I would have written that line of code (I use the new CAT() functions, such as the CATX() function that you suggested). Originally at university I was taught the pipe symbol (|) that you mentioned, prior to the introduction of the CAT() functions in SAS, but the exclamation is certainly the rarer symbol that I don't often see.
I read once that it is considered to be an outdated SAS programming style to still use symbols instead of the CAT() functions. Does anyone have an opinion on that? I think SAS courses these days only teach the CAT() functions now from what I've seen.
SAS supports a lot of their "old" coding so production jobs don't break. Try to find "Do over" in the documentation for example for use with arrays. Still works.
Because of the almost universal need for Strip() with || to get expected results I suspect that is major reason for teaching the CAT functions.
Of course Strip, to me, is a "new" function having learned Trim(left(variable)) before it was introduced.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.