help xml_tab-------------------------------------------------------------------------------

Title

xml_tab-- Save results in XML format

Syntax

xml_tab[namelist] [,options]where

namelistis a list of stored estimations or matrices; seeestimates. Anamelistcomprises one or more specifications, separated by spaces. A specification can be a name of a stored estimation or a matrix name.xml_tabwill output the estimation coefficients and one of the three statistics (standard errors, t-ratio, or p-values).For estimation results

xml_tabhas enough information to calculate significance levels itself but if a matrix to be outputted,xml_tablooks also formatname_STARS matrix that must be of same size asmatnameand contain values 0,1,2 or 3 denoting significance levels. See optionstarsfor more details.The stored estimation could be also specified in an extended form with parameters.

xml_tab[estname1(stat11 stat12, eform_option)[estname2(stat21 stat22)[...]]] [,options]where

estnameis a name of the stored estimation, andstat1andstat2are the names of matrixes stored ine(). Specificationestname(b V)is identical toestname. You can access the names of the stored matrixes withereturn list. See examples;The extended form specification is useful when accessing non-standard statistics, for example, when outputting marginal effects of the parameters after e.g.,

mfx,dprobit. The extended form could also be used when outputting the results in exponentiated forms after commands such asstreg,stcox,st, etc.Note that you may enclose

filenamein double quotes and must do so iffilenamecontains blanks or other special characters.

optionsDescription ------------------------------------------------------------------------- Outputsave(["]filename["])name and path for the output filereplaceoverwrite existingfilenameappendif workbookfilenameexists, add a new sheet, otherwise create a new workbooksheet(name[,sh_opts])worksheet where the table is outputted

color(#)specify tab color for a worksheetnogridlineshide gridlines on a worksheet

savemat(name[,sm_opts])save estimates to a matrix

replaceif matrixnamealready exists replace it. The default is to appendexitafter writing the matrix exitxml_tabwithout creating an output file

mv(mvspec)change missing values to string or numeric values.Statistics

sdshow estimated coefficients and standard deviations (default)tstatshow estimated coefficients and t-statisticpvalueshow estimated coefficients and p-valuestats(scalarlist)reportscalarliststatistics in the tablestars(starspec)controls significance levels and symbolsnoadjustreport not adjusted t-statisticseform_optiondisplay exponentiated coefficients. see eform_option;Table Layout

belowshow standard deviation (t-statistics or p-values) under the estimatesnobracketsremove brackets around standard deviation (t-statistics or p-values)rightshow standard deviation (t-statistics or p-values) next to the estimates (default)longlong output table stylewidewide output table style (default)keep(keeplist)reportkeeplistrowsdrop(droplist)dropdroplistrows from the tableequations(matchlist)match the equations of the models according tomatchlistTable Formatting

format(string)description of the output table formatlines(string)rows to be underlinednolabeldisplay variable names instead of labelsconstant(string)specifies label for the constantrblanks(string)add rows to the tablecblanks(cblist)add blank columns to the tablecwidth(cwlist)modify column widthstblanks(#)add blank rows at the top of the tabletitle(string)table titlernames(string)custom row namescnames(string)custom column namesceq(string)custom column equation names (super-titles)notes(string)add notes to the end of the tablefont(string)specifies font for a worksheetstyle(stylename)predefined format styles for outputSystem options

excelpath(["]filename["])specifies the location of theMS Excelexecutablecalcpath(["]filename["])specifies the location of theOO Calcexecutablenoisilydisplays the complete list of options applied to the tableupdateoptsforces the options file update

Description

xml_tabsaves Stata output directly into XML file that could be opened withMicrosoft ExcelorOpenOffice Calc. The program is relatively flexible and produces print-ready tables inExcelorCalc.xml_taballows users to apply different formats to the elements of the output table and essentially do everythingMS ExcelorOO Calccan do in terms of formatting from within Stata.

xml_tabcan create formatted tables of coefficients, standard errors, t- and p- values, summary statistics, etc., after any Stata estimation command that saves its results ine(). The program allows saving the results of a single estimation or a matrix into a table, combining several stored estimations or matrixes into one table, and outputting several tables into the different sheets of XML workbook.Calling

xml_tabwithout any arguments saves the results of last estimation command into filestata_out.xmllocated in the current work directory. After the XML file is savedxml_tabcan create links in the Stata Results window. Clicking on a link opens the output table inMSExcelorOO Calc. See system options for details.

xml_tabcan combine multiple estimations saved usingestimates storecommand. The example of outputting multiple estimates into one table might look as follows:

.sysuse auto

.regress price rep78 length mpg

.estimates store reg1

.regress price rep78 length mpg turn if foreign==1

.estimates store reg2

.xml_tab reg1 reg2In this very simple example, the estimates from the first regression are saved under the name

reg1. The specification of the second regression contains one extra variable and the sample for the estimation is constrained. The estimates from the second regression are saved under the namereg2.xml_tabcreates an output table containing five columns. The first column contains the names of the variables used in either regression. The second and the fourth columns contains the estimated coefficients of the first and the second regression, and the standard errors of the coefficients are outputted in columns 3 and 5.

xml_tabhas many additional options to control the outputted statistics, formatting and a general layout of the output tables. Please read the description of these options below and have a look at our examples.

Options+--------+ ----+ Output +-----------------------------------------------------------

save(["]filename["])specifies a name for XML file where tables are outputted. Ifsave(["]filename["])is omitted, the output will be saved instata_out.xmllocated in the current working directory. Useappendandreplaceoptions to instructxml_tabto append a table into the new worksheet of the existing file or to replace the existing file.Alternatively, the output file name can be specified with the

usingsyntax. Instead ofsave()users can write:

.xml_tab using c:\tmp\xml_out.xml, *

replacepermits to overwrite the existing XML file.

appendif XML file already exists, a new sheet will be added to it where the output table will be saved. Otherwise the new file will contain one sheet with the output.

NOTE:You need to close XML file opened in Excel or Calc forxml_tabto save new tables there. If XML file is still opened,xml_tabreports an error message: file can not be saved at this location.

sheet(name)You can output several tables into the different sheets of XML file (workbook). Excel or Calc files could contain multiple worksheets within a single document (workbook).sheet()option specifies the name for the new sheet where the table will be outputted. If not specified, a worksheet namedSheet1will be added.A valid Excel worksheet name must have no more than 31 characters. The worksheet name cannot contain any of the following: : \ / ? * [ or ] and can not be left blank.

savemat(name)saves estimation results in a matrix. Ifnameexists and optionreplacewas not used then additional rows will be appended to that matrix. In this case number of columns in the existing matrix and the one to be appended must be the same. The output matrix will contain estimates and standard errors (t-statistics, p-values) in a form determined by table layout options. Significance level info will be saved/appended toname_STARS matrix, see exporting a matrix example.

mv(#|mvc=#[\mvc=#...] [\else=#])specifies the new values (string or numeric) to which the missing values ate to be changed.

mv(str)specifies that all types of missing values be changed tostr.

mv(mvc=str)specifies that occurrences of missing-value codemvcbe changed tostr. Multiple transformation rules may be specified, separated by a backward slash\. The list may be terminated by the special ruleelse=str, specifying that all types of missing values not yet transformed be set tostr.For example:

mv(""),mv(.n="N.A." \ .d="(dropped)" \ else="")back to top

+------------+ ----+ Statistics +-------------------------------------------------------

sd,tstatandpvaluecontrol what statistic will be outputted together with the estimated coefficient. If optionsdis specified, the standard errors of the estimated coefficients are outputted. Specifyingtstatproduces a table of coefficients and the t-statistics.pvaluesoutputs the probability that the true value of the estimated coefficient is zero.Only one option can be specified. If no options are specified

sdthe standard deviations are outputted.

stats(scalarlist)specifies one or more statistics (scalars) to be displayed in the table. The statistics specified instatsare outputted at the end of the table and could be the number of observation stats(N); adjusted R2 for a regressionstats(r2_a); value of log-likelihoodstats(ll) and any statistics that are saved in e() scalars after estimation routines. Seeereturn.In addition

scalarlistmay contain the following statistics:

aicAkaike's information criterionbicSchwarz's information criterionrankrank ofe(V)- number of free parameters in modelIf several estimations are combined in one table the specified statistics will be displayed for each estimation.

stars(starspec)specifies the significance level(s) and the symbol(s) for the coefficients to be marked in the output table. The simple syntax forstarspecmay contain up to three numbers separated by spaces corresponding to significance levels denoted by one, two and three stars. Ifnumlistis just one number, the coefficients with the p-value less than that number will be marked by a star. For example, optionstars(0.1)will mark with one star all the coefficients with p-value less than 0.1. If two values are specified in thenumlist,xml_tabwill mark with one star the coefficients with p-values that are less or equal to the first value and grater than the second value. Coefficients with p-values less than the second value will be marked by two starts. For example, specifying {opt stars(0.1 0.05)} will put one star on coefficients with pvalues in the range from 0.1 to 0.5 and put two stars on the coefficients with p-value less than 0.5.The extended syntax allows selecting the symbols to mark the significance leves. In this case, {bf starspec} consist of up to three symbol/number pairs. The symbol could by one or several characters and the number indicates the significance level similar to the simple syntax described above.

By default,

xml_taboutput tables with the followingstarspecification:star(0.1 0.05 0.01). Alternatively, this option could be specified in the extended syntax asstar(*0.1**0.05***0.01). Note that any symbol or a combination of several symbols cold be used instead of * in this specification. Specifying 0 in the numlist would suppress stars on the table:star(0).

noadjustis used when outputting some transformations of the estimated coefficients (i.e. marginal effects). By default,xml_tabcalculates t-statistics as f(b)/sd_f(b). But ifnoadjustis specified then t-stat=b/sd_b will be reported and used for p-values and significance calculations.

eform_optionwhen this option is specified the coefficients and the standard errors (t-statistics and p-values) forallestimation results will be reported in exponentiated form. To transform only some of the estimation results, the extended syntax can be used. For example,

.xml_tab reg streg(, hr) prob, replaceoutputs unmodified coefficients and standard errors for esimations

regandprob, but exponentiated (Hazard ratio) coefficients and modified standard errors for the estimationstreg(displaying 'Haz Ratio' as a title).back to top

+--------------+ ----+ Table Layout +-----------------------------------------------------

belowandrightcontrol whether the standard deviation, t-statistic or p-values (see sd tstat pvalue) will be placed to the right or below the coefficients.rightis used by default.For example: if

rightis specified the element of the output table will look like:

0.1230.456if

belowis specified the element of the output table will look like:

0.123(0.456)

nobracketsremoves brackets around standard deviations (t-statistics or p-values), which is the default format whenbelowis used.

longandwideproduce "long version" or "wide version" of output table.widespecifies that the individual equations from multiple-equation models (e.g., mlogit, biprobit, heckman) to be placed in separate columns. Summary statistics will be reported under the first equation ifwideis specified. This is a default option.For example if a dependent variable with three categories is fitted with

mlogitusing 10 exogenous variables, specifyingwideoption would result in a 12x5 table. The first column of this table contains variable labels/names, the second and third columns contain the estimated coefficients and a standard errors for the first equation, and the fourth and fifth columns contain the estimated coefficients and a standard errors for the second equation.Alternatively, specifying option

longplaces the equations of the multiple-equation estimation below one another in a single column.

keep(keeplist)specifies the coefficients (and their order) to be included in the table. Akeeplistcomprises one or more specifications, separated by a space: a variable name (e.g., price), and equation name (e.g., mean:), or a full name (e.g., mean:price).Using

keepin a multiple-equation or in multiple-estimation tables would output only variables specified in thekeeplist. If some of the equations/estimations contain no variables inkeeplist, these equations will not be outputted.If you want to keep some variables only in selected equations, make sure you specify the correct names for the equations.

xml_tabuses the name of a dependent variable as an equation name.keepwill output statistics for the variables inkeeplistin all estimation/equations with identical names (same dependent variable).

drop(droplist)identifies the coefficients to be dropped from the table. Adroplistcomprises one or more specifications, separated by spaces. A specification can be either a variable name (e.g. price), an equation name followed by a colon (e.g. mean:), or a full name (e.g. mean:price).

drop(droplist)option could be useful if a user wants to suppress the output of coefficients for some variables. For example, if the empirical specification includes several regional dummies, one might want to create the output tables without the coefficients on these dummies. If regional dummies are named reg1,...,reg12, specifyingdrop(reg*)will suppress the output of the coefficients on these dummies in the table.In the multi-equation estimations (e.g.,

heckman,heckprobit) sometimes you might want to suppress the output of the coefficients for first stage equation. This could be done by specifyingdrop(select:), where select is the name of the first stage equation. See more example of usingdrop()option in Examples section.Characters * and ? can be used for variable names in the

keeplistanddroplist. The * character indicates to match one or more characters and the ? character matches a single character. All variables matching the pattern will be a included in the lists.

.xml_tab, droop(region_*).xml_tab, droop(region_?)In this example, the first command will suppress the output of coefficients for variables region_1-region_15, but the second one will output just suppress the coefficients for region_1-region_9, because only the one digit(character) was allowed by ?.

If both

keep()anddrop()are specified,keepwill be applied first.

equations(matchlist)specifies how the equations of the models innamelistare to be matched. This option works exactly the same way asequationsinestimates table; see estimates_options for details.back to top

+------------------+ ----+ Table Formatting +-------------------------------------------------

format(flist)specifies a list containing the formatting information for each cell of an XML table. The format of each cell is defined by a formatting string. A formatting string consists of five alpha-numerical symbols in the order specified bellow:

Cell type : (S|s) - string, (N|n) - numeric Vertical alignment: (T|t|1) - Top , (C|c|2) - Center, (B|b|3) - Botto > m Horizontal alignment: (L|l|1) - Left, (C|c|2) - Center, (R|r|3) - Rig > ht Font style: (R|r|0) - Regular, (B|b|1)- Bold, (I|i|2) - Italic, (O|o| > 3) - Bold Italic, (U|u|4) - Underline Decimal places : 0-9 defining number of digits after the decimal

The order of codes in the formatting string is important. The formatting string can contain a mixture of alpha-numerical symbols. Upper and lower-case character and numerical codes can be used interchangably. For example, a formatting string can look like N2210, NCCI2, nT1R0, sccb0 etc.

The formatting for a table of size nxm is described as a list of codes for table's columns. That list has a form:

((F_00 F_01...F_0n) (F_10 F_11...F1_n) ... (F_n0 F_n1...F_mn))Format lists for the different columns are enclosed in parenthesis and separated by a space. The first format list (F_00 F_01...F_0n) defines format for the rownames (e.g. variable names). The list (F_k0 F_k1...F_kn) describes formatting of cells of the

k-th column; the F_k0 defines the format for thek-th column's header (e.g. coeff. std.err.).If the dimensions of the formatting list are smaller than the dimensions of the output table, the formatting will be extended for the remaining rows/columns. If just one formatting code is specified as in

format((S2110))(string, centered vertically, left justified, in bold, with 0 decimal places), that format will be applied to each cell of the output table (including variable names and column headers). If two codes are specified as informat((S2110)(N2230)), the column with variables names will be formatted using S2110 format and all other columns in the table will be formatted with N2230. Specifying three codes (format((S2110)(NCCI0)(N2211))) will apply format S2110 to the column of variable names; format N2230 to all odd numerical columns; and format N2211 to all even numerical columns of the table.Similarly, is

k+1formatting codes are specified the first format will be applied to the column of the variable/row names and remainingkformats will be applied repeatedly to every group of k columns of the table. By specifying more than one formatting code for a column you can control the formatting of every cell in a column.Analogously to the extension rule for the column formats, the first code of the list will be applied to the column header and the next codes will be used repeatedly for the cells of a column. For example, format((S2110) (SCCB0 N2302 N2322)) outputs the variable names with format S2110, the headers for each numerical column with format S2210 format; every odd row has a format N2302 (right justified with 2 decimals) and every even row is formatted with N2322 (italic with 2 decimals).

See

stylesfor an alternative way of specifying the formatting of the output table.

lines(string)will draw the bottom borderline in the cells with the listed variables.stringis list of paired parameters. The first parameter specifies the variable name (or row number) and the second parameter a line style. The line style can be a number from 0 to 13 that corresponds to the line styles defined below. In addition, specifyingSCOL_NAMES,COL_NAMESandLAST_ROWinstead of variable namesxml_tabwill draw lines under equation names (SCOL_NAMES), statistic titles (e.g., coeff. std.error)COL_NAMESor under the last row of table (LAST_ROW).

Line #Style

#Style

0None1Continuous hairline2Continuous thin3Continuous medium4Continuous thick5Dot thin6DashDotDot thin7DashDotDot medium8DashDot thin9DashDot medium10Dash thin11Dash medium12SlantDashDot thin13Double thickFor example,

lines(COL_NAMES 1 turn 1 LAST_ROW 13)draws a single line under the captions (e.g., coeff std.err), a single line under the variableturn, and draw a double line under the last raw of the table.

nolabelby default, variable labels will be displayed as row names in the output table. Ifnolabelis specified, variable names will be displayed in the output table. This option is ignored when outputting matrixes.

constant(string)controls the label for the constant term. The default in Stata is_cons, but if specified,stringwill be displayed instead.

rblanks(varname[text][format],[varname[text][format]],[...])inserts an empty row or text after the specified rows (varname) in the output table. For each inserted rowxml_tabexpects variable namevarnameafter which an empty row or text should be added, the text itselftext, and format for a new cellformat. Multiple rows are separated by comma. Also seeformat.For example,

rblanks(turn "this text after turn" S2210, headroom "and this one below headroom") will add vertically and horizontally centered "this text after turn" below data row for variable calledturn(if found) and "and this one below headroom" after variable headroom using the same format as for headroom.In addition, specifying

SCOL_NAMES,COL_NAMESandLAST_ROWinstead of variable namesxml_tabwill add a row under equation names (SCOL_NAMES), statistic titles (e.g., coeff. std.error)COL_NAMESor under the last row of table (LAST_ROW).

cblanks(Equations|numlist)inserts an empty column after each column specified in thenumlist. The numbering of the numeric columns in the output table starts from 1, For example,cblanks(2 4)inserts an empty column after the second and the fourth columns of the output table. Column with the row names is number 0. If keywordEquations(abbreviation allowed) is used then blank column will be added after every equation (group of columns having the same column equation value).

cwidth(string)controls the column withs in Excel worksheet.stringis list of paired parameters. The first parameter specifies the column number (0 being the row names column) or keywordEquationsand the second parameter a column width. You can specify a column width of 0 to 255. This value represents the number of characters that can be displayed in a cell that is formatted with the standard font. If the column width is set to 0, the column is hidden.cwidthis evaluated after thecblanksoption so additional blank columns (if any) should be taken into consideration when determining column numbering.

tblanks(#)inserts#rows at the beginning of an Excel sheet. The output table shifts down by # rows.

title(string)specifies the title for the table. Thestringis inserted at the top of table. Example:

.xml_tab *, title("Table 1.1")

rnames(string),cnames(string)andceq(string)modify default row/column names as well as column equation names (super-titles) for the output matrix/estimation result.stringshould contain as many words as rows/columns in the output. To specify a name containing spaces it must be included in quotes. Table formating optionslong,below,keep(),drop(),rblanks()andcblanks()will be applied before thernames(),cnames(string)andceq(string).

notes([#]line1[,[#]line2[,...]])adds one or more lines of text at the end of the table. Lines are separated by commas. If first word (after comma) of a line specification is numeric then the note will be shifted down by#rows, otherwise it will be written imediately after the previous output row.

font("FontName"[Fontsize])specifies the font for the output table in a particular sheet of the workbook. TheFontNameis a font name enclosed in quotes; an optional argumentFontSizeis the size of the font. Example:

.xml_tab *, font("Arial Narrow" 12)If no

fontis specified, the defualt font is used. When a new sheet is added to the existing workbook andfontis specified, thatfontwill be applied only to the table in this new sheet. So, each sheet in the workbook can use differnt fonts.

nogridlineshides gridlines on a worksheet. The default in Excel is to display gridlines. This option affects only the on-screen appearance, these lines are not printed.

style(stylename)specifies layouts and formatting for the output table from predefined list of styles. These predefined styles are stored in thexml_tab_options.txt. If file is missing it will be recreated. There are several preset styles: default, S1, S2. user-defined styles can be added to the file. If neitherstylenorformatwas specified, the program creates output withstyle(default).

stylesinxml_tabare just sets of options that are written in filexml_tab_options.txtlocated in the directory wherexml_tabis installed. Eachstyleis recorded on the separate line. You can define your own styles by modifying filexml_tab_options.txt. The syntax for the styles consist of the style name, equal sign, and the set of options corresponding to that particular style. To create a style, add a new line in the filexml_tab_options.txtand define your style. For example:

MYTABLES=sd right replace wide font("Arial Narrow" 12) sheet(Table 1)You can instruct

xml_tabto use this style by specifying:

xml_tab *, style(mytables)This command will create a table using the set of options defined in

style(mytables). In other words, the previous command is equivalent to:

xml_tab *, sd right replace wide font("Arial Narrow" 12) sheet(Table1)User-specified options supersede any options defined in style. You can check the complete set of options associated with a particular style by using option

noisily.back to top

+---------------------------------------+ ----+ System requirements and other options +----------------------------

xml_tabis designed for Stata Version 8.0 and later. The XML files generated byxml_tabcould be opened with 2003 or later versions ofMicrosoft ExcelandOpenOffice Calc 2.0under Windows OS. It might be possible to open XML files withMS Excel 2002. The XML format is not supported byMS Excel 2000and earlier.We have not tested the compatibility of XML output generated by

xml_tabwithOpenOffice CalcorMicrosoft Excelrunning under Macintosh, UNIX, or Linux OS. We would be thankful for the comments from the users running Stata on these platforms about any problems they encounter with usingxml_tab.

xml_tabwill try to locate eitherMS ExcelorOO Calcon your computer and if found, will create a link in the results window clicking on which will automatically open the output. You can explicitly specify where shouldxml_tablook forExcelorCalcif the programs are installed not in their default locations (you will need to do it just once). If neither of two programs was found or Stata runs in "console" or "batch" modes, no link will be created butxml_tabwill still generate the output file.

excelpath(["]filename["]),calcpath(["]filename["])tellsxml_tabwhere to find Excel and/or Calc executables, for example:

.xml_tab, excelpath("D:\My programs\MS Excel\excel.exe")

.xml_tab, calcpath("D:\My programs\OpenOffice.org\scalc.exe")

noisilydisplays the complete list of options applied to the table. This option could be useful whey usingstylein order to see all options associated with a particular style.

updateoptsis used to recreate the options file. ifxml_tab_options.txtis missing, it will be created automatically, otherwiseupdateoptscan be specified to overwrite the existing options file with the one containing the default styles.

which xml_tabdisplays the version and location ofxml_tabinstalled on the computer. The latest version of the program can be installed in Stata by typing:

.adoupdate xml_tab, updateback to top

Examples+--------------+ ----+ Introduction +-----------------------------------------------------

In all our examples we use stored estimates and matrixes defined by the code below:

.sysuse auto, clear

.regress price mpg headroom trunk if foreign==0

.estimates store reg1

.regress price mpg headroom trunk turn if foreign==1

.estimates store reg2, title(Only foreign cars)

.heckman mpg weight length, sel(foreign = length displ) nolog

.estimates store heck1, title(Selection model)In the above code we use datafile

auto.dta. We run a regression and save the results of this regression into the stored estimatereg1. We then run another regression with a different specification and save the results in the estimatereg2giving this estimate a title. Then we estimateheckmanselection model. We store the estimates from this model toheck1.+--------------+ ----+ Basic syntax +-----------------------------------------------------

.xml_tab reg1 reg2, replace stats(r2_a) title("price regressions by cartype")In this example,

xml_tabmerges the estimates of two regressionreg1andreg2forming a table with five columns. The first column contains the variable names; the second column contains the estimated coefficients from the first regression; the third column contains the standard errors for the coefficients from the first regression; the estimated coefficients and the standard errors from the second regression are placed in the fourth and fifth columns of the output table.In addition to the coefficients and standard errors

xml_tabalso outputs the adjusted R2 for each regression at the bottom of the output table (optionstat(r2_a). With optiontitle("price regressions by car type")xml_tabis instructed to place a text "Price regression by car type" on the top of output table. The numerical values in the table are formatted with a default format: both the a coefficients and the standard errors have three decimal places, standard errors are placed to the right from the coefficients and italicized.The table is outputted into the file

stata_out.xmllocated in the current Stata directory.

Extensions:optionsbelow, tstat, save, sheet

.xml_tab reg1 reg2 using "c:\my documents\table1", tstat belowsheet("Table 2") stats(N r2_a)

save()saves the XML file asc:\my documents\table1.xml. The output table is placed in the sheet of XML workbook with the nameTable 2. Specifyingtstatoutputs the estimation coefficients and the corresponding t-statistics. Optionbelowplaces t-statistics in parenthesis under the coefficients.

Extensions:optionsappend, drop/keep

.xml_tab heck1 using "c:\my documents\table1", pvalue rightdrop(length) sheet("Heckman") stats(ll) appendThis command saves the estimation results from

heckman. Optionappendadds a new sheet "Heckman" to XML file used in the previous example and outputs there the estimated coefficients and p-values for the binary and continuous parts of the ML Heckman estimation. Optiondrop(length)suppresses the output of the estimated coefficient forlength.stats(ll)reports log-likelihood value for the system at the bottom of the table.To suppress the output of the binary part of the ML Heckman estimation (loosely speaking to supers the output of the first stage equation), we insert the equation name as a parameter:

drop(foreign:).

Extensions:optionslong and wideBy default,

xml_taboutputs the results of multiple-equation estimations into separate columns for each equation. For example, the table formed in the last example consists of five columns: column with the variable names, two columns with the coefficients and p-values from the first stage equation, and two columns with the second stage equation estimates. To output the coefficients from both equations into one column, specify optionlong:

.xml_tab heck1 using "c:\my documents\table1", long pvalue rightsheet("Heckman_long") stats(ll) appendNote that the code above will keep two previous tables saved in sheets

Table 1andHeckmanin the filec:\my documents\table1.xml_tabwill add a new sheetHeckman_longto the workbook and output the results in long specification into this sheet.

+--------------------+ ----+ Print ready tables +-----------------------------------------------

xml_taballows to create print-ready tables from within Stata. Several options control the look of the output table.Subcategories of variables could be conveniently separated using

rblanks()option. The example below inserts an empty row after variablempgand puts a heading in italic into this row:

.xml_tab reg1 reg2, replace stats(r2_a) rblanks(mpg "InteriorDimensions" S2220)To separate the results of two regressions, use option

cblanks()that insert an empty column after the columns specified as argument of this option. The code below inserts an empty column after the third column (standard errors of the first regressions).

.xml_tab reg1 reg2, replace stats(r2_a) cblanks(3)Option

line()allows to underline rows of the table. To underline the last row of the output table with a double line use the following syntax:

.xml_tab reg1 reg2, replace stats(r2_a) line(LAST_ROW 13)To underline the row with coefficient

mpgwith a single line and to underline the last row of the table with a double line use:

.xml_tab reg1 reg2, replace stats(r2_a) line(LAST_ROW 13 mpg 1)+------------------+ ----+ Marginal effects +-------------------------------------------------

You have to use a non-standard specification in order to create tables of marginal effects, elasticities, and other statistics generated by

mfx,dprobit, anddlogit. Suppose we want to generate a table of marginal effects afterheckmanestimation.

.heckman mpg weight length, sel(foreign = length displ) nolog.mfx, predict(xb).estimates store heck_mfx, title(Heckman marginals)Now, if we want to output, for example, the marginal effects from this estimation we write:

.xml_tab heck_mfx(Xmfx_dydx Xmfx_se_dydx), replaceTo output the marginal effects and the standard errors after

dprobityou would specify(dfdx se_dfdx)statistics.Note that now we specify the names of matrixes with corresponding statistics parenthesis with the name of the stored estimates. You can check the names of the matrixes with stored statistics using

ereturnlist.+--------------------+ ----+ Exporting a matrix +-----------------------------------------------

xml_tabcan also output any matrix in Stata memory. You can apply most of the options ofxml_tabto control the layout and the formatting of the matrix output. You can create custom tables forming the matrixes of results and outputting them withxml_tab.tabstatmatis a useful command to save various summary statistics into matrixes. The example below outputs matrixMwith a custom format into the default XML file.

.matrix M = 1, 2 \ 3, 4.matrix M_STARS = 0, 2 \ 3, 1.xml_tab M, format((S2210, S2100, S2100), (S2210, N2301, N2301),(S2230, N2321, N2321))Since matrix

M_STARSexists, output table will contain significance stars based on default levels and symbols. Thus, the output table will have a form:

c1c2r1 1.02.1** r2 3.0*4.1***

Another example demonstrates how to create and output a simple table of the means:

.tabstat price mpg rep78 headroom trunk weight length, by(foreign) save.tabstatmat A.matrix TAB=A'

.xml_tab TAB, replace

tabstatgenerates a table of means for the list of variables categorized byforeigh.tabstatmatsaves the resutls to matrix A. This matrix has tree rows for Domestic, Foreign and Total. In the columns of matrix A are the means for the listed variables. We save the transpose matrix A into another matrix TAB.xml_tabouptuts the matrix into the default XML file.You can see more examples of using

xml_tabinxml_tab_example.do.

AuthorsZurab Sajaia, zsajaia@worldbank.org

Michael Lokshin, mlokshin@worldbank.org

econ.worldbank.org/programs/poverty/toolkit

Development Economics Research Group,

The World Bank, 2006

AcknowledgementWhile the concept of

xml_tabis original, we borrowed some functionality ideas from such programs asestoutby Ben Jann,outregby John Luke Gallup,outreg2by Roy Wada,modltblby John H. Tyler,mktabby Nicholas Winter,outtexby Antoine Terracol, orest2texby Marc Muendler.

Also seeOnline:

xmlsave,estimates,matrix,which