Example: bankruptcy

Syntax - Stata: Software for Statistics and Data Science

Manipulate labelsSyntaxMenuDescriptionOptionsRemark s and examplesStored resultsReferencesAlso seeSyntaxLabel datasetlabel data["label"]Label variablelabel variablevarname["label"]Define value labellabel definelblname #"label"[#"label"..][, add modify replace nofix]Assign value label to variableslabel valuesvarlist[lblname|.][, nofix]List names of value labelslabel dirList names and contents of value labelslabel list[lblname[ ]]Copy value labelslabel copylblname lblname[, replace]Drop value labelslabel drop{lblname[ ]|all}Save value labels in do-filelabel save[lblname[ ]]usingfilename[, replace]where#is an integer or an extended missing value (.a,.b,..,.z).12 label Manipulate labelsMenulabel dataData>Data utilities>Label utilities>Label datasetlabel variableData>Variables Managerlabel defineData>Variables Managerlabel valuesData>Variables Managerlabel listData>Data utilities>Label utilities>List value labelslabel copyData>Data utilities>Label utilities>Copy value labelslabel dropData>Variables Managerlabel saveData>Data utilities

Value labels are attached to variables by label values. label values attaches a value label to varlist. If . is specified instead of lblname, any existing value label is detached from that varlist. The value label, however, is not deleted. The syntax label

Tags:

  Sciences, Value, Syntax, The value

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Syntax - Stata: Software for Statistics and Data Science

1 Manipulate labelsSyntaxMenuDescriptionOptionsRemark s and examplesStored resultsReferencesAlso seeSyntaxLabel datasetlabel data["label"]Label variablelabel variablevarname["label"]Define value labellabel definelblname #"label"[#"label"..][, add modify replace nofix]Assign value label to variableslabel valuesvarlist[lblname|.][, nofix]List names of value labelslabel dirList names and contents of value labelslabel list[lblname[ ]]Copy value labelslabel copylblname lblname[, replace]Drop value labelslabel drop{lblname[ ]|all}Save value labels in do-filelabel save[lblname[ ]]usingfilename[, replace]where#is an integer or an extended missing value (.a,.b,..,.z).12 label Manipulate labelsMenulabel dataData>Data utilities>Label utilities>Label datasetlabel variableData>Variables Managerlabel defineData>Variables Managerlabel valuesData>Variables Managerlabel listData>Data utilities>Label utilities>List value labelslabel copyData>Data utilities>Label utilities>Copy value labelslabel dropData>Variables Managerlabel saveData>Data utilities>Label utilities>Save value labels as do-fileDescriptionlabel dataattaches a label (up to 80 characters) to the dataset in memory.

2 Dataset labels aredisplayed when youusethe dataset and when youdescribeit. If no label is specified, any existinglabel is variableattaches a label (up to 80 characters) to a variable. If no label is specified, anyexisting variable label is definedefines a list of up to 65,536 (1,000 for Small Stata) associations of integers andtext called value labels. value labels are attached to variables bylabel valuesattaches a value label tovarlist. specified instead oflblname, any existingvalue label is detached from thatvarlist. the value label, however, is not deleted. The syntaxlabelvaluesvarname(that is, nothing following thevarname) acts the same as specifying Valuelabels may be up to 32,000 characters dirlists the names of value labels stored in listlists the names and contents of value labels stored in copymakes a copy of an existing value dropeliminates value savesaves value labels in a do-file.

3 This is particularly useful for value labels that are notattached to a variable because these labels are not saved with the [D]label languagefor information on thelabel Manipulate labels 3 Optionsaddallows you to add# labelcorrespondences tolblname. Ifaddis not specified, you may createonly newlblnames. Ifaddis specified, you may create newlblnamesor add new entries to you to modify or delete existing# labelcorrespondences and add new correspon-dences. Specifyingmodifyimpliesadd, even if you do not type , withlabel define, allows an existing value label to be , withlabelcopy, allows an existing value label to be copied , withlabel save, allowsfilenameto be display formats from being widened according to the maximum length of the valuelabel.

4 Considerlabel values myvar mylab, and say thatmyvarhas a% formatright now. Say that the maximum length of the strings inmylabis 12 valueswould change the format ofmyvarfrom% also allowed withlabel define, but it is relevant only when you are modifying anexisting value label. Without thenofixoption,label definefinds all the variables that use thisvalue label and considers widening their display and [U] Dataset, variable, and value labelsfor a complete description of labels. This entrydeals only with details not covered dirlists the names of all defined value listdisplays the contents of avalue 1 Althoughdescribeshows the names of the value labels, those value labels may not exist.

5 Statadoes not consider it an error to label the values of a variable with a nonexistent label. When thisoccurs, Stata still shows the association ondescribebut otherwise acts as if the variable s valuesare unlabeled. This way, you can associate a value label name with a variable before creating thecorresponding label. Similarly, you can define labels that you have not yet use describeContains data from : 1,130vars: 7 22 Jan 2013 11:12size: 19,210storage display valuevariable name type format label variable labelid str10 %10s Record identification numbercity byte % int % byte % byte % byte % byte % sexlblSorted by:4 label Manipulate labelsThe dataset is using the value labelsexlbl.

6 Let s define the value labelyesno:. label define yesno 0 "no" 1 "yes"label dirshows you the labels that you have actually defined:. label diryesnosexlblWe have two value labels stored in can display the contents of a value label with thelabel listcommand:. label list yesnoyesno:0 no1 yesThe value labelyesnolabels the values 0 asnoand 1 you do not specify the name of the value label on thelabel listcommand, Stata lists all thevalue labels:. label listyesno:0 no1 yessexlbl:0 male1 femaleTechnical noteBecause Stata can have more value labels stored in memory than are actually used in the dataset,you may wonder what happens when yousavethe dataset. Stata stores only those value labelsactually associated with youusea dataset, Stata eliminates all the value labels stored in memory before loadingthe can add new codings to an existing value label by using theaddoption with thelabeldefinecommand.

7 You can modify existing codings by using themodifyoption. You can redefinea value label by specifying 2 The labelyesnocodes 0 asnoand 1 asyes. You might wish later to add a third coding: 2 asmaybe. Typinglabel definewith no options results in an error:. label define yesno 2 maybelabel yesno already definedr(110);If you do not specify theadd,modify, orreplaceoptions,label definecan be used only tocreatenewvalue labels. Theaddoption lets you add codings to an existing label:label Manipulate labels 5. label define yesno 2 maybe, add. label list yesnoyesno:0 no1 yes2 maybePerhaps you have accidentally mislabeled a value . For instance, 2 may not mean maybe but mayinstead mean don t know.

8 Adddoes not allow you to change an existing label:. label define yesno 2 "don t know", addinvalid attempt to modify labelr(180);Instead, you would specify themodifyoption:. label define yesno 2 "don t know", modify. label list yesnoyesno:0 no1 yes2 don t knowIn this way, Stata attempts to protect you from yourself. If you typelabel definewith nooptions, you can only create a new value label you cannot accidentally change an existing one. Ifyou specify theaddoption, you can add new labels to a label, but you cannot accidentally changeany existing label. If you specify themodifyoption, which you may not abbreviate, you can changeany existing can even use themodifyoption to eliminate existing labels.

9 To do this, you map the numericcode to anull string, that is,"":. label define yesno 2 "", modify. label list yesnoyesno:0 no1 yesYou can eliminate entire value labels by using thelabel 3We currently have two value labels stored in memory sexlblandyesno as shown by thelabel dircommand:. label diryesnosexlblThe dataset that we have in memory uses only one of the labels thatyesnois not being used:6 label Manipulate labels. describeContains data from : 1,130vars: 7 22 Jan 2013 11:12size: 19,210storage display valuevariable name type format label variable labelid str10 %10s Record identification numbercity byte % int % byte % byte % byte % byte % sexlblSorted by:We can eliminate theyesnolabel by typing.

10 Label drop yesno. label dirsexlblWe could eliminateallthe value labels in memory by typing. label drop _all. label dirThe value labelsexlbl, which no longer exists, was associated with the variablefemale. Evenafter dropping the value label,sexlblis still associated with the variable:. describeContains data from : 1,130vars: 7 22 Jan 2013 11:12size: 19,210storage display valuevariable name type format label variable labelid str10 %10s Record identification numbercity byte % int % byte % byte % byte % byte % sexlblSorted by:label Manipulate labels 7 Stata does not mind if a nonexistent value label is associated with a variable.


Related search queries