Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2023-06-08 19:25:09
Size: 515
Comment:
Revision 3 as of 2025-10-24 16:52:01
Size: 497
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]].
Line 31: Line 31:
[[https://www.stata.com/manuals/dassert.pdf|Stata manual for assert]] [[https://www.stata.com/manuals/dassert.pdf|Stata manual for -assert-]]

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)