Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: Constructing a group level variable


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Constructing a group level variable
Date   Wed, 10 Feb 2010 17:39:25 +0100

<> 

This is "so not elegant" :-(


*************
clear*

input byte schid   studid  byte timep08  byte timef08
  2     6910          2          2
  2     6911          2          2
  2     6912          2          3
  2     6913          3          3
  4     7299          2          2
  4     7300          2          2
  4     7301          3          1
  4     7302          2          2
  4     7303          2          2
  4     7304          2          1
  4     7305          1          . 

end

reshape wide time*, i(schid) j(studid)

forv i=1/3{
	egen byte timep`i' = anycount(timep0*), values(`i')
	egen byte timef`i' = anycount(timef0*), values(`i')
}

drop timep0* timef0*
order schid timep* timef*

l, noo
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von
[email protected]
Gesendet: Mittwoch, 10. Februar 2010 17:25
An: [email protected]
Cc: [email protected]
Betreff: st: Constructing a group level variable

Hi all,

I have a dataset that consists of students (studid) in 49 schools
(schid) responding to a survey. They were asked their impressions of the
curriculum ("do you believe time devoted to subject xxx was ....") and
all responses were categorical (with 1 denoting 'not enough', 2 denoting
'just right', and 3 being 'too much'). A slice of the data is:

list    schid studid timepub08 timefin08 in 30/40

    +--------------------------------------+
    schid   studid   timep~08   timef~08
    --------------------------------------
30.    2     6910          2          2
31.    2     6911          2          2
32.    2     6912          2          3
33.    2     6913          3          3
34.    4     7299          2          2
    --------------------------------------
35.    4     7300          2          2
36.    4     7301          3          1
37.    4     7302          2          2
38.    4     7303          2          2
39.    4     7304          2          1
    --------------------------------------
40.    4     7305          1          .
    +--------------------------------------+

Question: Is there a way to generate a (or collapse this) dataset to get
school levels variables? I am interested in school level variables that
captures the number of responses to each category (1 'not enough' 2
'just right' and 3 'too much') for each question (timepub08 timefin08).

Many thanks for the advice.


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


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



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