Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: One-way table and multiple variables


From   Eric Booth <ebooth@ppri.tamu.edu>
To   "<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu>
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**
table rep78, center c(n price n mpg n headr) 
table rep78, center c(n price n mpg n headr) by(for)


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

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

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:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index