Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Collapsing large datasets using MATA

    Dear all,

    I am aware of these old (but still quite interesting) discussions about the relative speed of -collapse when one uses large datasets: http://www.stata.com/statalist/archi.../msg00498.html

    I face the same problem today. I must collapse very large datasets several times, and using the good old -collapse works, but takes ages to complete.

    I tried the Mata route, but I am fairly new to Mata.
    I downloaded MOREMATA but I am not able to run a collapse with a 2-key identifier using mm_collapse

    For instance, following the mm_collapse official documentation I tried to replicate
    Code:
    sysuse auto 
    collapse price turn, by(make rep78)
    in MATA by typing

    Code:
     
    sysuse auto
    mata: X  = st_data(., ("price", "turn"))
    mata: ID = st_data(., ("make", "rep78"))
    mata: mm_collapse(X, 1, ID)
    without success. I get an error message that seem to imply that mm_collapse only works with single vectors id. Am I right?
    Is there a mistake in my code?

    Many thanks!
Working...
X