0% found this document useful (0 votes)
306 views2 pages

Stata Operators

This document summarizes arithmetic, relational, and logical operators in Stata. It defines common operators like addition, subtraction, multiplication, division, exponentiation, equality, inequality, AND, OR, and NOT. Examples are provided to illustrate how each operator is used. Operators are executed in a specific order of evaluation from highest to lowest precedence.

Uploaded by

Rosetta Renner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
306 views2 pages

Stata Operators

This document summarizes arithmetic, relational, and logical operators in Stata. It defines common operators like addition, subtraction, multiplication, division, exponentiation, equality, inequality, AND, OR, and NOT. Examples are provided to illustrate how each operator is used. Operators are executed in a specific order of evaluation from highest to lowest precedence.

Uploaded by

Rosetta Renner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Contents:

(1) Stata Arithmetic/String Operators


(2) Stata Relational Operators
(3) Stata Logical Operators

(1) Stata Arithmetic/String Operators

Symbol Definition Example Result

^ Exponentiation (power) A^3 raise A to the third


power

* multiplication (table 2*y multiply 2 by the value


note 1) of Y

/ division var/5 divide the value of VAR


by 5

+ addition num+3 add 3 to the value of


NUM

+ String concatenation "this" + "that" concatenate the string


values “this” and “that”

- negation sale-discount subtract the value of


DISCOUNT from the
value of SALE
Any arithmetic operation on a missing value or an impossible arithmetic operation (e.g., division by zero) yields a
missing value.

(2) Stata Comparison Operators

Symbol Definition Example

== equal to a==3

^= not equal to a ^= 3

~= not equal to

> greater than num>5

< less than num<8

>= greater than or equal to sales>=300

<= less than or equal to sales<=100


A double equal sign (==) is used for equality testing.
(3) Stata Logical Operator

Symbol Definition Example

& and (a>b & c>d)

| or (a>b or c>d)

! not !(a>b or c>d)

~ not

The order of evaluation (from first to last) of all operators is ! (or ~), ^, - (negation), /, *, -
(subtraction), +, != (or ^=), >, <, <=, >=, ==, &, and |.

You might also like