DATA Step, Macro, Functions and more

where is the documentation of " variabel in: ( .... )"?

Accepted Solution Solved
Reply
Super Contributor
Posts: 297
Accepted Solution

where is the documentation of " variabel in: ( .... )"?

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

 


Accepted Solutions
Solution
‎09-27-2016 07:29 AM
Super User
Posts: 19,770

Re: where is the documentation of " variabel in: ( .... )"?

Posted in reply to JacobSimonsen

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


All Replies
Solution
‎09-27-2016 07:29 AM
Super User
Posts: 19,770

Re: where is the documentation of " variabel in: ( .... )"?

Posted in reply to JacobSimonsen

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

 

Super Contributor
Posts: 266

Re: where is the documentation of " variabel in: ( .... )"?

Posted in reply to JacobSimonsen

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

 

Super Contributor
Posts: 297

Re: where is the documentation of " variabel in: ( .... )"?

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:-)

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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