sas function " !! "

Reply
Occasional Contributor yym
Occasional Contributor
Posts: 6

sas function " !! "

[ Edited ]

Hi folks, has anyone used “!!”? what is the difference between !! and ||? The code below gave me the same result.

 

data t;

input a1 $ a2 $;

datalines;

ab ac

aa b

cc c

aa aa

;

run;

 

data tt;

set t;

var=a1!!a2;

var2=a1||a2;

run;

Super User
Posts: 3,235

Re: sas function " !! "

There is no difference - both are synonyms for doing character variable concatenations.  

Occasional Contributor
Posts: 5

Re: sas function " !! "

they have the same meaning "concatenation", so yes, you will get the same result. which one you use is up to you. I prefer the pipe symbol myself for concatenating character variables.

Super User
Posts: 11,134

Re: sas function " !! "

Once upon a time long long ago many keyboards and some of the multiple operating systems SAS runs on did not have the pipe character available. Hence use of ! instead of |.

Super User
Posts: 19,156

Re: sas function " !! "

The table at the bottom of this page does a good job of summarizing the operators:

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm
Super User
Super User
Posts: 7,720

Re: sas function " !! "

Also, one other thing to note is that with later versions of SAS there have been several concatenation functions added which make code both more readble, shorter, and add extra functionality (such as add a delimiter or use arrays).  In most cases I would use those rather than the pipe or !, however there is still uses for them.  

CAT

CATS

CATT

CATX

etc.

http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#n1e21rr6al5...

 

Occasional Contributor yym
Occasional Contributor
Posts: 6

Difference between !! and ||

Hi folks, has anyone used “!!”? what is the difference between !! and ||? The code below gave me the same result.

 

data t;

input a1 $ a2 $;

datalines;

ab ac

aa b

cc c

aa aa

;

run;

 

data tt;

set t;

var=a1!!a2;

var2=a1||a2;

run;

Super User
Posts: 5,386

Re: Difference between !! and ||

So...

It's all in the documentation...

There might be some difficulties to use || in a native Z/OS windows.

Data never sleeps
Contributor dkb
Contributor
Posts: 53

Re: Difference between !! and ||

This is an exact duplicate of https://communities.sas.com/t5/General-SAS-Programming/sas-function-quot-quot/m-p/237247

 

It's not usually a good idea to start off multiple identical threads, because it makes it difficult for everyone including yourself to keep track of what's been suggested.

Occasional Contributor yym
Occasional Contributor
Posts: 6

Re: Difference between !! and ||

it is my first time to post here and not familiar with different sections of the community. I was not able to find the original post so re-posted it. sorry for the duplicate

Super User
Super User
Posts: 7,720

Re: Difference between !! and ||

Several people have already answered that for you, there is no difference.  My post was an addendum to that to point out that functions are available to help readability and add additional functionality.

Ask a Question
Discussion stats
  • 10 replies
  • 493 views
  • 1 like
  • 8 in conversation