Thanks, xcontract worked perfectly.
Now I have an additional question. My dataset of cell frequencies
(created by xcontract) has something like 140,000 observations. My
original dataset has 648,000 observations. I need to attach the cell
frequencies back to the original dataset. I thought this would be
something like -merge, but it wants unique observations...
Imagine something like this in the original data:
religion race gender
1 1 1
1 1 1
1 1 2
1 2 1
1 2 1
the data created by -xcontract are:
religion race gender _freq
1 1 1 2
1 1 2 1
1 2 1 2
I want my original dataset to be:
religion race gender _freq
1 1 1 2
1 1 1 2
1 1 2 1
1 2 1 2
1 2 1 2
I tried -merge ....., uniqusing
where my frequency dataset was the using dataset, but it was still
looking for unique values of the -merge varlist in the master dataset.
Thanks,
Larry
On 11/1/05, Roger Newson <[email protected]> wrote:
> Another possibility might be to use -xcontract- (downloadable from SSC),
> which abbreviates Joseph's solution, as in
>
> xcontract religion gender age ethnicity, list(, noobs separator(0))
>
> The -xcontract- package can also produce an output dataset (or resultsset)
> containing the table cells for future use, as in
>
> xcontract religion gender age ethnicity, saving(mycells1, replace)
>
> which creates a Stata dataset (or resultsset) in -mycells1.dta- with 1
> observation per table cell. This resultsset can then be processed in any
> way the user likes, to produce plots and tables.
>
> I hope this helps.
>
> Roger
>
>
> At 13:48 01/11/2005, Bill Gould wrote:
> >Lawrence Hanser <[email protected]> asked
> >
> > > Is it possible to do greater than two-way cross-tabulations? For
> > > example, if I have religion (10 categories), gender (2 categories),
> > > age (4 categories), and ethnicity (6 categories), is there a simple
> > > command to get the counts for each of the 480 cells?
> >
> >Joseph Coveney <[email protected]> suggested
> >
> > . preserve
> > . contract religion gender age ethnicity
> > . list, noobs separator(0)
> > . restore
> >
> >Anotehr possibility is
> >
> > . table age ethnicity gender, by(religion)
> >
> >-table- produces tabular output, which Lawrence may prefer. -table-, however,
> >does not generalize beyond 4-way tables, as Joseph's solution does.
>
>
> --
> Roger Newson
> Lecturer in Medical Statistics
> Department of Public Health Sciences
> Division of Asthma, Allergy and Lung Biology
> King's College London
>
> 5th Floor, Capital House
> 42 Weston Street
> London SE1 3QD
> United Kingdom
>
> Tel: 020 7848 6648 International +44 20 7848 6648
> Fax: 020 7848 6620 International +44 20 7848 6620
> or 020 7848 6605 International +44 20 7848 6605
> Email: [email protected]
> Website: http://phs.kcl.ac.uk/rogernewson/
>
> Opinions expressed are those of the author, not the institution.
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/