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