Nice, Fast and Automating table in Stata 16 using xtable

Nice, Fast and Automating table in Stata 16 using xtable.

Many times you will think that if you can export tables automating from Stata to Excel instead right click and copy and paste to Excel.

Indeed in Stata 16 and below doesn't have the automating export table to Excel. Yes, there are commands like putexcel and putdocx, but it's not convenient for non-programers.

There is a command contributed by Stata user name Weverthon Machado. This command is xtable. This command can export the table using the command table in Stata.

Let's install this command in Stata. First, let's describe the module using the command:

ssc describe xtable

ssc describe xtable
ssc describe xtable

Then you have two options to install the xtable into Stata 16.

Firstly, click on the blue command ssc install xtable from the describe result above. Or Secondly, you can type the command below directly to the Command Bar:

ssc install xtable

ssc install xtable
ssc install xtable

Let's use the xtable command. Please download the dataset from here.

use Province_code.dta, clear

xtable province_code, filename(province) sheet(province) row

Results:

xtable result in Stata 16
xtable result in Stata 16

Now you can open the Excel file by clicking on the filename province.xlsx. Or you can file the file in the directory, please make sure that you can find it in the right location.

Tips: You can use command putexcel to do more with this table such as merge cells, bold format, add table tile or even functions.

Now it's your turn to use this command in your real working life.


Reference:

https://ideas.repec.org/c/boc/bocode/s458658.html

Comments