Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Cross-tabulation of data


From   hmjc66 <[email protected]>
To   statalist <[email protected]>
Subject   st: Cross-tabulation of data
Date   Sat, 30 Jun 2007 07:10:45 -0400

Hi,

I posted my question yesterday, but realized there were some errors as
Nick rightly pointed out. Here is another attempt at what I am trying
to do.

Assume my data is as follows:-

id	q23	q24	q25	q29	q30	q31
1	3	1		1	4	
2	4	2	3	5	3	2
3	2			2		
4	3			3		
5	1	3	2	4	6	1

q23-q25 and q29-q31 are categorical variables.
q23-q25 each has 4 categories 1, 2, 3 & 4. I want to ignore category 4.
q29-q31 each has 6 categories 1, 2, 3, 4, 5 & 6. I want to ignore category 6.

I am interested in a cross tabulation.

Here's what I need:-

count if q23==1 & (q29==1 | q29==2);
count if q24==1 & (q30==1 | q30==2);
count if q25==1 & (q31==1 | q31==2);

/* I then need to sum these */; Lets call the total "a"

count if q23==1 & q29==3;
count if q24==1 & q30==3;
count if q25==1 & q31==3;


/* I then need to sum these */; Lets call the total "b"


count if q23==1 & q29==4;
count if q24==1 & q30==4;
count if q25==1 & q31==4;

/* I then need to sum these */; Lets call the total "c"

count if q23==1 & q29==5;
count if q24==1 & q30==5;
count if q25==1 & q31==5;

/* I then need to sum these */; Lets call the total "d"


THEN GO THROUGH THE SAME PROCEDURE using q23=2, q24=2 & q25=2. Assume
the four values generated are e, f, g and h

FINALLY DO THE SAME using q23=3, q24=3 & q25=3. Assume the four values
generated are i, j, k and l


I finally need the results in a table such as

	NP	FP	G
< 24%	a	e	i
25-49%	b	f	j
50-74%	c	g	k
75%	d	h	l
I am using STATA 9.

Any help would be much appreciated, since it is driving me nuts!

Hugh
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index