Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Lucas <lucaselastic@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
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 matching. Any ideas on how to do this will be greatly appreciated! Thanks a bunch. Sam * * 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/