- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Two exclamation marks are one method to write the simple concatenation operator.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Two exclamation marks are one method to write the simple concatenation operator.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.