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]

st: Contract/Collapse Combination

From   Lucas <>
Subject   st: Contract/Collapse Combination
Date   Mon, 21 May 2012 13:45:25 -0700

So, I am attempting to construct a file containing a list-format 15
(or so) -way crosstab, with frequencies of cases for each combination
of values.  I have millions of cases, so this crosstab is appropriate.

What would be ideal would be the ability to use the contract command
but, instead of only indicating the need for one count,  could ask for
the sum of two variables.  Assume I have a dichotomous variable (say,
"enter college).  Those who enter college are coded 1, those who do
not are coded zero.  I could then construct a new variable, named
"DidNotEnter", coded 1 for those who do NOT enter college, and zero
for those who do.

If I could then write something like:

collapse x1 x2 x3 x4 ... xj, freq(EnterCol) freq(DidNotEnter)  zero

I could get the totals needed.  The plan is to speed processing of a
computationally difficult model by substituting a model of counts for a
model of individual cases.  To do this I need the total count of each
combination and the count meeting the condition (e.g., entering college).
My code above would, if possible, produce a file that allowed me to
add the two frequencies to get the total.

As far as I can tell, this is not possible.  What seems to be required
is to run it with only the "Enter College" freq, then somehow break
the two cases (EnterCollege=1 vs. EnterCollege=0) (or, alternatively,
to keep EC==1 and run it, and then re-run with EC==0) and somehow
combine them, an operation that seems to be begging for error in

Any ideas on how to do this will be greatly appreciated!

Thanks a bunch.

*   For searches and help try:

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