Stata - How to use the collapse command

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ม.ค. 2025

ความคิดเห็น • 9

  • @midori8er
    @midori8er 2 ปีที่แล้ว +2

    Concise and informative!

  • @henryschneider9101
    @henryschneider9101 ปีที่แล้ว +1

    Very helpful!

  • @ashley.f6702
    @ashley.f6702 ปีที่แล้ว

    you are my life saver.

  • @siriosnes6018
    @siriosnes6018 7 หลายเดือนก่อน +1

    Thank you, it was helpful. But why does the "collaps" command create a new dataset and delete the old. Is there a similar command that does the same thing, but creates new aggregate variables within the existing dataset?

    • @SteffensClassroom
      @SteffensClassroom  7 หลายเดือนก่อน

      Thank you for the comment!
      The collapse creates a new dataset on the basis of summary statistics of the old dataset. That is the purpose of the command. If you really want to keep the old dataset, simply wrap the collapse command in a preserve/restore group, creating a new dataset, saving it, and then merge it onto the old. I explained the preserve/restore and merge in two other videos.

  • @anonymous-421
    @anonymous-421 ปีที่แล้ว +1

    How to collapse on mode for categorical variables?

    • @SteffensClassroom
      @SteffensClassroom  ปีที่แล้ว

      Hi!
      Never tried but my suggestion would be first use egen to generate the mode, and then you can keep the first obs when using collapse.

  • @kraxhaug2279
    @kraxhaug2279 ปีที่แล้ว +1

    i get error message from this code: collapse (sum) project1, by(countryname, year, internationalsectorname). why :(

    • @SteffensClassroom
      @SteffensClassroom  ปีที่แล้ว

      Good idea to show the error message toy get so we have an idea what is going on :)