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

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;

 

1 ACCEPTED SOLUTION
5 REPLIES 5
Buzzy_Bee
Quartz | Level 8

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.

ballardw
Super User

@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.

Buzzy_Bee
Quartz | Level 8

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.

ballardw
Super User

@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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

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
  • 5 replies
  • 1271 views
  • 3 likes
  • 3 in conversation