help for mkcorr

Generate correlation table formatted for easy inclusion in articles

mkcorr varlist [if exp] [in range] , log(filename) [replace means nocorr sig lab num cdec(#) mdec(#) casewise]


mkcorr produces a correlation table in a format that is easy to import into a spreadsheet or word processing document. In this, it is inspired by the indispensable mktab and outreg commands. By writing the output directly to a logfile, it avoids two problems with taking correlation tables from the results window. First, it allows an effectively unlimited number of variables without wrapping around. Second, it requires less post-processing in a spreadsheet or word-processor, particularly for more involved tables. It also offers a number of small advantages such as allowing the use of labels, controlling the number of decimal places used, and other formatting options.


log(filename) specifies the name of the file in which the output is to be stored. The output file, filename.log, can be opened with any spreadsheet or word-processing program. If the user specifies a file name that includes an extension, that extension will be used rather than .log. Thus, log(foo.out) yields the logfile foo.out. The filename specification may include the path of a directory other than the current working directory.

replace must be specified for the log file to replace an existing file of the same name.

means requests that summary statistics (mean, s.d., min, max) be included.

nocorr suppresses the output of the correlation table. It is only sensible in combination with means as a way to output descriptive statistics.

lab uses variable labels rather than variable names.

num is a formatting option that labels each variable with a number in the first column and uses the same numbers as the column headers for the correlation table. This is especially useful when you have either a large number of variables or variables with long names.

sig requests that the significance of each correlation be printed under it.

cdec(#) set the number of decimal places displayed in the correlation table.

mdec(#) set the number of decimal places displayed in the summary statistics portion of the table.

casewise cause the table to reflect casewise deletion. In other words, results will reflect only those observations for which no listed variables are missing. This command will yield results identical to using corrrelate. The default is to engage in pairwise deletion, yielding results identical to using pwcorr.


.mkcorr price mpg, log(auto) replace

.mkcorr price mpg, log(auto) replace num label

.mkcorr price mpg, log(auto) replace label means mdec(2) cdec(3)


This is version 2.0 of this software. It should be preferred to any version 1.x. Please inform the author of any bugs you find.


Glenn Hoetker, College of Business, University of Illinois at Urbana-Ch > ampaign ghoetker@uiuc.edu


This program owes a debt of inspiration to mktab, outreg and corrtab. The helpful feedback of Nick Cox, Jonathan Gardner and Stephen Jenkins contributed to substantial improvements from version 1.0 to version 1.3. Comments from Herve Stolowy contributed to significant improvement from version 1.3 to 2.0.

Also see

On-line: help for correlate and pwcorr.