Export Matrix of correlation to Excel

This page discusses various options available in asdocx for exporting a matrix of correlation to Excel. The basic syntax for correlation command is given below:

asdocx cor [varlist] [if] [in], [nonum label dec(#) asdocx_options]


nonum : By default, asdocx writes the column header as (1), (2), … (n) while creating a table of correlations. Option nonum will force asdocx to write variable names as column headers.

label : By default, asdocx writes variable names as the row headers of the correlation table. Option label can be used to use variable labels instead of variable names.

dec(): The dec(#) can be used to specify the number of decimal points to be reported. For example, dec(2) will report correlation coefficients with two decimal points.

Other asdocx options are acceptable with correlation commands [See Section 1 for more details].
Specifically, these options are frequently used with correlation commands: save(filename), replace, title(table_title) and fs(#).

Example 1: Zero setup

* Use the auto dataset
sysuse auto, clear

* Use .xlsx extension to send the output to Excel
asdocx cor, save(Table1.xlsx)

asdocx export correlation to excel


Example 2: Export Variable labels

* Export labels :  Note we do no need the save(Table.xlsx) 
* anymore in the current session
asdocx cor, save(Table1.xlsx) label

Export correlation excel variable label asdocx


Example 3: Correlations among selected variables

asdoc cor price trunk length weight, replace