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

Re: st: survey data: how does one generate category, scale, score counts?


From   Ulrich Kohler <[email protected]>
To   [email protected]
Subject   Re: st: survey data: how does one generate category, scale, score counts?
Date   Mon, 8 Jul 2002 10:11:47 +0000

Carsten Baumann  wrote
> I am trying to summarize results from a survey with about 28,000
> participants.  What I am trying to do seems simple, however, I need help.
>  A former colleague of mine used to do similar work in SPSS using the
> AGGREGATE command and then OUTFILE with a BREAK by (sub)categories.  Any
> tips on how to do this are greatly appreciated.
>
> I am working with student survey results with the following variables:
>
> WTSKUL (value 0 to 2)
> BUILDING (value 20 to 8000)
> GRADE (value 6 to 12)
> SEX (value 1 to 2)
> ETHNICITY (value 101 to 109
> SCALE1
> SCALE2
> ....
> SCALE110
>
> The scales have values (or SCORES) from 0 to 8
>
>
> What I need is to generate a long file with a COUNT by BUILDING by CATEGORY
> (Grade, Sex, or Ethnicity) by SCORE for each SCALE.  That is, how many
> FEMALES (CATEGORY 1) in BUILDING == 20 received a SCORE == 1 on SCALE1.
>  For example:
>
> BUILDING 	CATEGORY	SCALE		SCORE		COUNT
> 20		1		SCALE1	1		458
> 20		1		SCALE1	2		657
> 20		2		SCALE1	1		20
> 20		101		SCALE1	1		54
> 20		109		SCALE1	4		333
>
> repeat with each SCALE
>
> repeat for each BUILDING

As far as I unterstand, this should do the trick:

.. gen count = 1 if score = 1
.. by BUILDING CATEGORY SCALE, sort: replace count = sum(count)
.. by BUILDING CATEGORY SCALE, sort: replace count = count[_N]


There is an article in the Stata Journal on how to do thinks like this:

Cox, N.J (2002): Speaking Stata: How to move step by: step. Stata Journal 2, 
86--102

hope that helps
uli

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