Transcription of Syntax - Stata
1 Display generic error message and exitSyntaxDescriptionRemarks and examplesAlso seeSyntaxerrorexpDescriptionerrordisplay s the most generic form of the error message associated with expression and setsthe return code to the evaluation of the expression. If expression evaluates to 0,errordoes , the nonzero return code will force anexitfrom the program orcaptureblock in whichit the return code to 197 if there is an error in and are presented under the following headings:IntroductionSummaryOther messagesIntroductionerroris used in two ways inside programs. In the first case, you want to display a standard errormessage so that users can look up your message by usingsearch:if ( nvals >100) error 134 According to [R]search, return code 134 is associated with the message too many values . Duringprogram development, you can verify that by typing the error command interactively.
2 Error 134too many valuesr(134);Below we list the individual return codes so that you can select the appropriate one for use witherrorin your also used when you have processed a block of code in acaptureblock, suppressing alloutput. If anything has gone wrong, you want to display the error message associated with whateverthe problem was:capture {code continues}local rc=_rcpreserve return code fromcapturecleanup codeerror rc present error message andexitif necessarycode could continueUsually, one hopes that the return code will be zero so thaterrordoes error Display generic error message and exitYou can interrogate the built-in variablercto determine the type of error that occurred and thentake the appropriate action. Also see[U] Error handling in return codes are numerically grouped, which is a feature that you may find useful when youare writing programs.
3 The groups areReturn codesMeaning1 99sundry minor errors100 199syntax errors300 399failure to find previously stored result400 499statistical problems500 599matrix-manipulation errors600 699file errors700 799operating-system errors900 999insufficient-memory errors1000 1999system-limit-exceeded errors2000 2999nonerrors (continuation of 400 499)3000 3999 Mata run-time errors; see [M-2]errorsfor codes4000 4999class system errors9000 9999system-failure errorsSummary1. You pressedBreak. This is not considered an timed out -- see help r(2) for troubleshootingAn Internet connection has timed out. This can happen when the initial attempt to make a connection over theInternet has not succeeded within a certain time limit. You can change the time limit that Stata uses under thiscondition by typingset timeout1#seconds.
4 Or, the initial connection was successful, but a subsequent attempt tosend or receive data over the Internet has timed out. You can also change this time limit by typingset timeout2#seconds. See [R] dataset in useYou attempted to perform a command requiring data and have no data in ; data in memory would be lostYou attempted to perform a command that would substantively alter or destroy the data, and the data have notbeensaved, at least since the data were last changed. If you wish to continue anyway, add theclearoption tothe end of the command. Otherwise,savethe data sortedmaster data not sortedusing data not sortedThe observations of the data are not in the order required. To solve the problem, usesortto sort the data thenreissue the command; see [D] the second and third cases, both the dataset in memory and the dataset on disk must be sorted by the variablesspecified in the varlist ofmergebefore they can be sorts the datasets for you, unlessyou specify thesortedoption.
5 You specifiedsorted, but your dataset is not sorted on the variables in not Return code fromconfirm existencewhenstringdoes not found whereexpectedYou are using a program that is using theconfirmcommand to verify that what you typed makes sense. Themessages indicate what you typed and what the program expected to find instead of what you is falseno action takenReturn code and message fromassertwhen the assertion is false; see [D] , you were usingmvencodeand requested that Stata change . to#in the specified varlist, but#alreadyexisted in the varlist, so Stata refused; see [D] Display generic error message and exit must start with an empty datasetThe command (for example,infile) requires that no data be in memory you mustdropallfirst. You areprobably usinginfileto append additional data to the data in memory.
6 Instead,savethe data in memory,dropall,infilethe new data, and thenappendthe previously saved data; see [D] required= exp requiredusing requiredby() option requiredCertain commands require a varlist or another element of the language. The message specifies the required itemthat was missing from the command you gave. See the command s Syntax diagram. For example,mergerequiresusingto be specified; perhaps you meant to typeappend. Or,ranksumrequires aby()option; see [R] not allowedweights not allowedin range not allowedif not allowed= exp not allowedusing not allowedCertain commands do not allow anifqualifier or other elements of the language. The message specifies whichitem in the command is not allowed. See the command s Syntax diagram. For example,appenddoes not allow avarlist; perhaps you meant to few variables specifiedThe command requires more variables than you specified.
7 For instance,stackrequires at least two variables. Seethe Syntax diagram for the many variables specifiedThe command does not allow as many variables as you specified. For example,tabulatetakes only one or twovariables. See the Syntax diagram for the to inputYou gave theinputcommand with no varlist. Stata will input onto the end of the dataset, but there is no existingdataset here. You must specify the variable names on master butin using dataYou have attempted to append two datasets, but there is a string or numeric mismatch for one of the variables. Thefirst blank is filled in with a variable name, and the second and third blanks are filled in with a storage type (byte,int,long,float,double,str#, orstrL). You could specifyappend sforceoption to ignore the thestr#type is in the master data, the using variable would then be treated as if it contained"".
8 If thestr#type is in the using data, the using variable would then be treated as if it contained numeric missing variableis strL in using dataYou have attempted to merge two datasets, but one of the key variables is astrL. The blank is filled in withthe variable name. The key variables the variables on which observations are matched can bestr#, but theycannot possible with numeric variableYou have requested something that is logically impossible with a numeric variable, such as encoding it. Perhapsyou meant another variable or typedencodewhen you possible with string variableYou have requested something that is logically impossible with a string variable, such as decoding it. Perhaps youmeant another variable or typeddecodewhen you mismatchIn an expression, you attempted to combine a string and numeric subexpression in a logically impossible way.
9 Forinstance, you attempted to subtract a string from a number or you attempted to take the substring of a definedA variable or a value label has already been defined, and you attempted to redefine it. This occurs most oftenwithgenerate. If you really intend to replace the values, usereplace. If you intend to replace a value label,specify thereplaceoption with thelabel definecommand. If you are attempting to alter an existing label,specify theaddormodifyoption with thelabel error Display generic error message and foundno variables definedThe variable does not exist. You may have mistyped the variable s out of orderYou specified a varlist containingvarname1-varname2, yetvarname1occurs aftervarname2. Reverse the order ofthe variables if you did not make some other typographical error.
10 Remember,varname1-varname2is taken byStata to meanvarname1,varname2, and all the variables indataset orderin between. Typedescribeto see theorder of the variables in your found in using dataYou specified a varlist withmerge, but the variables on which you wish to merge are not found in the usingdataset, so themergeis not abbreviationYou typed an ambiguous abbreviation for a variable in your data. The abbreviation could refer to more than onevariable. Use a nonambiguous abbreviation, or if you intend all the variables implied by the ambiguous abbreviation,append a * to the end of the out of contextThis is the generic form of this message; more likely, you will see messages such as may not streset .You have attempted to do something that, in this context, is not allowed or does not make %formatYou specified an invalid%fmt; see[U] Formats: Controlling how data are codes 121 127 are errors that might occur when you specify a numlist.