confirm — Argument verification 5
or
’’ found where numeric variable expected
with a return code of 7 if varlist is not specified.
confirm string variable specifies that all the variables are strings, meaning str# or strL. If
the variable exists but is not a string variable, Stata displays the message
’varname’ found where string variable expected
or
’’ found where string variable expected
with a return code of 7 if varlist is not specified.
confirm str# variable specifies that all the variables are str#, such as str10 or str42, but
are not strLs.
confirm alias variable specifies that all the variables were created by fralias add. If the
variable exists but was not created by fralias add, Stata displays the message
’varname’ found where alias variable expected
confirm type variable specifies that all variables are of the indicated storage type. For example,
confirm int variable myvar, confirm float variable myvar thatvar, or confirm strL
variable blobvar. As with confirm string variable, the appropriate message and return code
of 7 are possible. When there is an alias variable in varlist, the linked variable’s storage type is
checked.
confirm new variable verifies that varlist can be interpreted as a new varlist. The possible
messages and return codes are
Message Return code
found where varname expected 7
already defined 110
invalid name 198
Example 1
confirm is a cheap way to include minimal syntax checking in your programs. For instance, you
have written a program that is supposed to take a one-integer argument. Although you do not have to
include any syntax checking at all —the program will probably fail with some error if the argument
is incorrect—it is safer to add one line at the top of the program:
confirm integer number ‘1’
Now if the first argument is not an integer, you will get a reasonable error message, and the program
will stop automatically.