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-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
  • 3 replies
  • 726 views
  • 0 likes
  • 3 in conversation