Return to Archive

SAS Tip of the Month
August 2004

SAS, like most other computer languages, use mathematical operators. The following table lists the most common operators used along with their definition and an example. Note that some operators have two or more forms, for example the Logical Not operator that can use either the "^", "~" or "NOT" symbols.

Symbol(s) Definiton Example
** exponentiation z=a**(0.5);
^,~,NOT logical not if ^missing(z) then z=1;
><,MIN minimum z=(x><y);
<>,MAX maximum z=(x<>y);
* multiplication z=x*y;
/ division z=x/y;
+ addition z=x+y;
- subtraction z=x-y;
||,!!, concatenate character values z='Mr. '||surname;
<,LT less than if x<y then z=1;
<=,LE less than or equal to if x<=y then z=2;
=,EQ equal to if x eq y then z=3;
^=,~=,NE not equal to if x^=y then z=0;
>=,GE greater than or equal to if x ge y then z=5;
>,GT greater than if x>y then z=6;
IN equal to one of a list if x in(1,2,3) then z=7;
&,AND logical and if x & y then z=8;
|,!,,OR logical or if x=1 or y then z=9;
________________________________
Updated August 1, 2004