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

Re: st: using creat count id on var


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: using creat count id on var
Date   Sun, 27 Feb 2005 14:45:43 -0500

At 06:34 AM 2/28/2005 +1100, Richard Hiscock wrote:
Thanks Nick for your reply
Im obviously finding it difficult to develop in this area
I cant find a useful guide,any pointers?

My problem now is that having identified the visitno within id I wish to perform manipulations on a variable. For example
using the illustrated structure.
To obtain the maximum value of var1 within id at each level of visitno.
To obtain the mean value of var1 within id at each level of visitno
Is this what you want?  (I'm using your earlier variable labeling).

. bysort id visitno: egen maxvar2 = max(var2)

. bysort id visitno: egen meanvar2 = mean(var2)

. list

     +---------------------------------------------------------+
     | id    date   var1   var2   visitno   maxvar2   meanvar2 |
     |---------------------------------------------------------|
  1. |  1   16267      x     53         1       106         79 |
  2. |  1   16267      y    106         1       106         79 |
  3. |  1   16267      y     84         1       106         79 |
  4. |  1   16267      y     90         1       106         79 |
  5. |  1   16267      z     76         1       106         79 |
     |---------------------------------------------------------|
  6. |  1   16267      z     65         1       106         79 |
  7. |  1   16298      x     87         2        87       81.5 |
  8. |  1   16298      y     76         2        87       81.5 |
  9. |  2   15678      x     98         1        98         98 |
 10. |  2   15678      y     98         1        98         98 |
     |---------------------------------------------------------|
 11. |  2   16541      x    150         2       150        150 |
     +---------------------------------------------------------+



-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX:    (574)288-4373
HOME:   (574)289-5227
EMAIL:  [email protected]
WWW (personal):    http://www.nd.edu/~rwilliam
WWW (department):    http://www.nd.edu/~soc

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