Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: tabdisp & collapse


From   James Cui <james.cui@med.monash.edu.au>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: tabdisp & collapse
Date   Tue, 19 Apr 2005 09:40:25 +1000

Thanks Keith. That will do, although I thought it may only need a couple of lines.

James.


Keith Dear wrote:

James - I don't know if you call this an easy way, but it works. I hope someone can do it better.
Keith

. list, clean
a b x
1. 0 0 15
2. 0 1 11
3. 1 0 20
4. 1 1 24

tempfile a b ab
preserve
collapse (sum) x, by(a)
save `a'
restore, preserve
collapse (sum) x, by(b)
save `b'
restore, preserve
collapse (sum) x
save `ab'
restore
append using `a'
append using `b'
append using `ab'


At 04:38 PM 18/4/05, you wrote:


Dear all:

Is there any easy way to transfer the following data

0 0 15
0 1 11
1 0 20
1 1 24

into

0 0 15
0 1 11
1 0 20
1 1 24
0 . 26
1 . 44
. . 70
. 0 35
. 1 35

Apparently, the added records with "." are the marginal totals and grand total. This question is related to the example given in the Programming Manual about tabdisp & collapse.

Thanks.

James
Email: James.Cui@med.monash.edu.au


*
* 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/


==========================================================
Dr Keith B.G. Dear
Senior Fellow in Biostatistics
National Centre for Epidemiology and Population Health (NCEPH)
The Australian National University
Canberra, ACT 0200, Australia
Tel: 02 612 54865, Fax: 02 612 50740
http://nceph.anu.edu.au/Staff_Students/staff_pages/dear.php
CRICOS provider #00120C

*
*   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/

--
James Cui, PhD MMed BSc (Stats)
Senior Research Fellow
Department of Epidemiology & Preventive Medicine
Monash University
Alfred Hospital, 89 Commercial Road
Melbourne, Victoria 3004
Australia
Tel: 990 30570
Fax: 990 30556
Email: James.Cui@med.monash.edu.au


*
*   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/



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