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

Hello everyone,

 

I just found in the documentation how the operator "=:" works. (much like the "like"-operator). I find this this veryy useful. I thereafter guessed that there might also exist a "in:" operator, which I found there indeed do exist. This allows users to search for the starting letters in several strings at same time. However, I can not find the description of the operator in the documentation - can anyone send a link, or is it only for experimental use?

 

Here an example:


data exclusion;
  format dx $8.;
  input dx $;
  if dx in: ('3912',  '429');
  cards;
3912 
3913
391218
x4290 
429
42901
;
run;

gives this dataset:

 

3912
391218
429
42901

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Operator is the same as =: but with OR between each item. 

 

X =: 'val1' or X =: 'val2'

 

Also, not just IN, you can add it to >,  <, etc, in fact:

You can add a colon ( : ) modifier to any of the operators to compare only a specified prefix of a character string. See Character Comparisons for details.

 

http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#p00iah2thp63bmn1lt20...

 

View solution in original post

3 REPLIES 3
Reeza
Super User

Operator is the same as =: but with OR between each item. 

 

X =: 'val1' or X =: 'val2'

 

Also, not just IN, you can add it to >,  <, etc, in fact:

You can add a colon ( : ) modifier to any of the operators to compare only a specified prefix of a character string. See Character Comparisons for details.

 

http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#p00iah2thp63bmn1lt20...

 

RahulG
Barite | Level 11

Go to this link

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm

 

Search for "Character Comparisons" on the web page. You would find documentation on =: operator

 

JacobSimonsen
Barite | Level 11

Yes, that right. It says ":" can be added any modifyer to compare only the prefix.

I would wish I had knew that earlier, which would have made life much easier:-)

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 908 views
  • 0 likes
  • 3 in conversation