BookmarkSubscribeRSS Feed
yym
Calcite | Level 5 yym
Calcite | Level 5

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;

10 REPLIES 10
yym
Calcite | Level 5 yym
Calcite | Level 5

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;

LinusH
Tourmaline | Level 20

So...

It's all in the documentation...

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

Data never sleeps
dkb
Quartz | Level 8 dkb
Quartz | Level 8

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.

yym
Calcite | Level 5 yym
Calcite | Level 5

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

SASKiwi
PROC Star

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

SASBob
Fluorite | Level 6

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.

ballardw
Super User

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

Reeza
Super User
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
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 10 replies
  • 1317 views
  • 1 like
  • 8 in conversation