Differences between revisions 1 and 2
Revision 1 as of 2023-06-08 19:25:09
Size: 515
Comment:
Revision 2 as of 2025-10-24 16:35:52
Size: 495
Comment: Rewrite
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
The '''`assert`''' command raises an error if a condition is not true. '''`-assert-`''' raises an error if a condition is not true.
Line 18: Line 18:
The `assert` command can also be used with [[Stata/Macros|macros]], [[Stata/Scalars|scalars]], and [[Stata/StoredResults|stored results]]. `-assert-` can also be used with [[Stata/Macros|macros]], [[Stata/Scalars|scalars]], and [[Stata/StoredResults|stored results]].

Stata Assert

-assert- raises an error if a condition is not true.


Usage

assert foo==1
assert foo==1 if bar==1

-assert- can also be used with macros, scalars, and stored results.

count if foo==1
assert r(N)==0


See also

Stata manual for assert


CategoryRicottone

Stata/Assert (last edited 2025-10-24 16:52:01 by DominicRicottone)