In my last post, I demonstrated how to use putexcel to recreate common Stata output in Microsoft Excel. Today I want to show you how to create custom reports for arbitrary variables. I am going to create tables that combine cell counts with row percentages, and means with standard deviations. But you could modify the examples below to include column percentages, percentiles, standard errors, confidence intervals or any statistic. I am also going to pass the variable names into my programs using local macros. This will allow me to create the same report for arbitrary variables by simply assigning new variable names to the macros. You could extend this idea by creating a do-file for each report and passing the variable names into the do-files. This is another important step toward our goal of automating the creation of reports in Excel.
Today’s blog post is Read more…
In my last post, I showed how to use putexcel to write simple expressions to Microsoft Excel and format the resulting text and cells. Today, I want to show you how to write more complex expressions such as macros, graphs, and matrices. I will even show you how to write formulas to Excel to create calculated cells. These are important steps toward our goal of automating the creation of reports in Excel.
Before we begin the examples, Read more…
For a long time, I have wanted to type a Stata command like this,
. ExcelTable race, cont(age height weight) cat(sex diabetes)
The Excel table table.xlsx was created successfully
and get an Excel table that looks like this:
So I wrote a program called ExcelTable for my own use Read more…
In a previous blog entry, I talked about the new Stata 13 command putexcel and how we could use putexcel with a Stata command’s stored results to create tables in an Excel file.
After the entry was posted, a few users pointed out two features they wanted added to putexcel:
- Retain a cell’s format after writing numeric data to it.
- Allow putexcel to format a cell.
In Stata 13.1, we added the new option keepcellformat to putexcel. This option retains a cell’s format after writing numeric data to it. keepcellformat is useful for people who want to automate the updating of a report or paper. Read more…
Update 07 June 2018: See Export tabulation results to Excel—Update for new features that have been added since this original blog.
There is a new command in Stata 13, putexcel, that allows you to easily export matrices, expressions, and stored results to an Excel file. Combining putexcel with a Stata command’s stored results allows you to create the table displayed in your Stata Results window in an Excel file. Read more…