Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: question about calculating frequencies
From 
 
Ekaterina Hertog <[email protected]> 
To 
 
"[email protected]" <[email protected]> 
Subject 
 
st: question about calculating frequencies 
Date 
 
Sat, 27 Mar 2010 20:52:25 +0100 
Dear all,
I have a dataset containing individuals and about 40 variables 
representing their interest in various activities. Each interest 
variable has a value of 1, 2 or 3 depending on the strength of interest 
expressed. I need to calculate numbers of men and women who expressed 
interest level 1 for each activity and then incorporate them as 
constants into my dataset.
At the moment my data looks like this:
id sex int_baseball int_music int_cinema
1    1           1        2    1
2    1           1        3    1
3    2           3        1    2
4    1           2        1    2
5    2           2        2    1
I am now using table command to create frequencies by sex for each 
interest separately:
table int_baseball, by(sex) replace
keep if int_baseball==1
rename table1 intbsbsexfreq
la var intbsbsexfreq "frequency of strong interest in baseball by sex"
compress
reshape wide intbsbsexfreq, i(int_baseball) j(sex)
la var intbsbsexfreq1 "number of men interested in baseball"
la var intbsbsexfreq2 "number of women interested in baseball"
having calculated number of men interested in baseball (15,000 in my 
case) and number of women interested in baseball (6000 in my case) I can 
then manually generate a constant variable in my name dataset:
gen menint_baseball=15000
but this method of arriving at what I need is really cumbersome, I would 
be most grateful for any suggestions of alternative more efficient 
commands I could use.
Warm regards,
katya
--
Ekaterina Hertog (née Korobtseva)
Career Development Fellow
Department of Sociology and Nissan Institute of Japanese Studies
University of Oxford
27 Winchester Road
Oxford
OX2 6NA
United Kingdom
*
*   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/