Statalist


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

st: collapse - mata question


From   Enzo Coviello <[email protected]>
To   [email protected]
Subject   st: collapse - mata question
Date   Mon, 31 Mar 2008 21:42:05 +0200

Dear Stata Users,

Assume that we have a matrix

1 1 0 28
1 1 1 27
2 0 0 26
2 1 1 25

In a corresponding Stata data set the first column is the variable -id-, the second is the variable -occ-, the third -ocx- and the fourth -day-

I want to obtain a matrix like that:

1 2 1 28
2 1 1 26

In the standard Stata language this is easy:
. collapse (sum) occ ocx (max) day, by(id)

I wonder how the same result can be obtained in mata?

Best wishes

Enzo



Enzo Coviello
Unit� di Epidemiologia e Statistica ASL BARI
Piazza V. Emanuele 14
70054 Giovinazzo (Bari)
Italy
tel./fax +39 080 3357867
mobile +39 347 5016 016
home +39 0883 695055


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