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.
To review, the basic syntax of putexcel is as follows:
putexcel excel_cell=(expression) … using filename[, options]
If you are working with matrices, the syntax is
putexcel excel_cell=matrix(expression) … using filename[, options]
In the previous blog post, we exported a simple table created by the correlate command by using the commands below.
. sysuse auto (1978 Automobile Data) . correlate foreign mpg (obs=74) | foreign mpg -------------+------------------ foreign | 1.0000 mpg | 0.3934 1.0000 . putexcel A1=matrix(r(C), names) using corr
These commands created the file corr.xlsx, which contained the table below in the first worksheet.
As you can see, this table is not formatted. So, I formatted the table by hand in Excel so that the correlations Read more…