Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: One-way table and multiple variables

From   Eric Booth <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: One-way table and multiple variables
Date   Thu, 25 Aug 2011 03:35:56 +0000


I'd start with -table- , or use a combination of -collapse- and some command to export your table (e.g., -outsheet- or Stata 12's - export excel-)  For example:

sysuse auto, clear

table rep78, center c(n price n mpg n headr) 
table rep78, center c(n price n mpg n headr) by(for)

**collapse & export**
collapse (count) price mpg headr, by(rep78)
lab var price "Freq Price"
lab var mpg "Freq MPG"
lab var headroom "Freq Headr"

outsheet using "test", replace
if "`c(version)'" == "12" export excel using "test2.xlsx",  ///
replace sheet("My Tables") firstrow(varl)

Also,  you can take advantage of the formatting and exporting features of some user-written table commands like -tabout- or -outreg2-  from SSC.  -findit table- shows many possibilities.

- Eric

On Aug 24, 2011, at 10:13 PM, Kingsley Wong wrote:

> Hi Statalisters,
> I am trying to create a table that shows the variables, variable values and frequencies in the following format:
>          var1 var2 var3
> value1 freq freq freq
> value2 freq freq freq
> ...
> All variables have the same set of values.
> I have tried -tab1- but it only creates one-way frequency table for each variable. Also, I have searched SSC but couldn't find a solution that suits my need. Your advice is appreciated. Thanks in advance.
> Regards,
> Kingsley
> *
> *   For searches and help try:
> *
> *
> *

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index