Bookmark and Share

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


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

st: Creating single crosstab table from two separate crosstabs


From   Scott Cunningham <[email protected]>
To   [email protected]
Subject   st: Creating single crosstab table from two separate crosstabs
Date   Mon, 21 Mar 2011 15:28:45 -0500

I am currently trying to automate a number of basic procedures for a
client, one of which involves calculating crosstabulations for a
survey questionaire.  The client has a question which can take on
values of 1, 2 or 3, and he is interested in seeing the joint
frequency of that value against two other separate variables, but he
wants to present all of the cross tabs in one table.  So that this is
concrete, I will outline what I am doing using the auto.dta dataset.
I want to ultimately have a single table in which each row is the
values from "rep78", and the columns are "headroom" followed by
"foreign", and then finally "total", and I've tried repeatedly to do
this using -estpost- and -estout-, because estpost is able with
unstack to transpose the values from the saved matrices to create the
columns the way that I desire. But it does not appear to have an easy
way to do this using two sets of stored matrices.  Below is my most
recent effort, which I reproduce only so that someone may have some
code to help them deiscern what I'm trying.

estpost tabulate rep78 headroom
matrix a=e(pct)
estpost tabulate rep78 foreign
matrix b=e(pct)
#delimit ;
estout matrix(a b) using ./test.tex, style(tex) label notype stats(a )
unstack replace;



sincerely,

Scott Cunningham
Assistant Professor
Dept of Economics
Baylor University
Waco, Texas 76798-8003
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index