Presentation is loading. Please wait.

Presentation is loading. Please wait.

Comparison of different output options from Stata

Similar presentations


Presentation on theme: "Comparison of different output options from Stata"— Presentation transcript:

1 Comparison of different output options from Stata
Emma Slaymaker Milly Marston Estelle Mclean

2 Output- Stata’s weak spot?
Stata has lacked commands to export nicely formatted results This is changing – Stata 13 introduced putexcel and _docx These have been expanded in Stata 14 User written commands for exporting particular sets of results Creative thinking with existing commands will get you a long way

3 Commands to output results
Existing: outsheet (reshape and collapse) file write New in Stata 13: putexcel _docx User- written: estout

4 Example data Using one of Stata’s example datasets
To get it type sysuse nlsw88,clear The do file for this presentation is on the CSM webpage Data from US National Longitudinal Survey of Mature and Young women (I think). Data on mean hourly wage by industry and some background characteristics.

5 Sample results (1): graph of hourly wage by industry

6 Sample results (2): Table showing the proportion of women who were in a union and the proportion who were college graduates, across the different industries.

7 Sample results (3): Linear regression of hourly wage by industry and background characteristics

8 outsheet turns datasets into spreadsheet format
outsheet saves the dataset in memory to a text file in a delimited format Most spreadsheet software will read this but won’t read a Stata dataset Default is a tab-delimited format columns of data (variables) are separated by tabs You can specify other delimiters

9 To simply make a table that you can use in Word or Excel
Three steps: Use collapse to get the summaries you want Use reshape to arrange the dataset like a spreadsheet table Use outsheet to save this as a text file

10 estout saves regression results in a text or HTML file
A user written command, to get it type: net search estout,pkg Click on the first entry and then the install link. Produces a text file containing stored estimates Step 1) Run regression model Step 2) Store results using estimates store mymodel Step 3) Use estout to create the results file Many, many options- best to look at the website:

11 _docx: Make your own Word documents
This is a Mata command Mata is one of Stata’s programming languages access it from within Stata using mata prefix Makes an Open Office Word document From your do file you can insert text, graphs, data from Stata’s memory matrices return results You can build custom tables You can format the contents of the document

12 _docx: Make your own Word documents
You tell Stata that you want a new word document and give it a file handle a short name to refer to it by Stata creates the file in memory As you carry out your analysis you send results to the file When you save the file, it is written to disk. You won’t see anything until you save it. You can write the file in any order, and go back and edit it.

13 _docx- the downsides It all seems a bit half-finished
Some of the documentation is not very helpful A lot of this isn’t documented in Stata help or the manuals, but this website is very useful- There is still a lot of formatting that you can’t do. Although the command writes an Open Office XML file, you can’t get at the XML

14 putexcel to make a spreadsheet of results
Quick and easy command Can make workbooks with multiple sheets Can add in all types of results and graphs (v 14 only) Need to manipulate stored estimates and returned results for best effect Can modify existing workbooks, and retain cell formats Control formats- better in Stata 14 than 13

15 putexcel the downsides
You have to specify destination cell references If the number of items in your results change then you need to update the destination references To fix this: you either need a lot of programming or a lot of work editing your do file

16 The file command Lets you read and write files outside Stata
Files either binary or text Simple principle Straightforward syntax Totally flexible A how to guide:

17 file write to make custom text files
Use with loops Extract results from return or ereturn Format them Send them to the text file Can optionally add tags for XML or LaTeX

18 Comparison of the different options
putexcel file write mata _docx File format: Excel- widely used Not tied to particular software Makes an Open Office doc Control over formatting results Can’t format results (Stata 13) Good control over formatting (Stata 14) Can format very well if include additional markup such as XML or LaTeX Can format results but some limitations (table columns) Ease of use Quick and easy version of command No simple option but easy to learn No simple option, need to know a bit of Mata Include graphs No (Stata 13) Yes (Stata 14) No- not in text files Yes - in HTML Yes

19 Comparison of the different options
putexcel file write mata _docx How much work to map out a structure for the results Easy to overwrite results, you must specify the correct row numbering No need to specify row numbers but you need structure do file to make sure things are written in correct columns Need to organise results and navigate row numbers in tables Sequence for writing the file You can write the worksheet in any order Only writes in order from top left to bottom right Can write and later modify things Number of files that can be written to at one time Only write to one file at a time with advanced syntax Easy to write to different files Can send output to different doc files from within same do file

20 What are they good for? file write putexcel mata _docx Flexibility
Tables Fast execution Repeated outputs putexcel Quickly dropping unformatted results into Excel Single outputs mata _docx Including image files into document Putting entire dataset into document (e.g. r(table) ) With additional markup (e.g. xml): - Lovely formatting - Structured workbooks


Download ppt "Comparison of different output options from Stata"

Similar presentations


Ads by Google