Collapsing Data in Stata

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 30

  • @SB-ez7wp
    @SB-ez7wp 5 лет назад +1

    Great video. I don't mean to "correct" you, but just to clarify for other viewers a tiny bit, at 5:20, the count option generates the number of individual observations with *non missing* values for the given variable, not just the number of individuals.
    For example, suppose that of the men from IL, 100 of them have a missing value for their wage. If that were the case, the collapse command would have placed a value of 1588 in the count variable for observation 1 rather than 1688.

    • @sebastianwaiecon
      @sebastianwaiecon  5 лет назад +1

      You're right. Thanks for the clarification. Missing data can be a bit tricky in Stata because it just sort of quietly deals with it in the background without telling you, and it can definitely trip people up.

  • @xovicente
    @xovicente 5 лет назад +1

    Thank you. I was so worried about my homework and this helped me a lot.

  • @cristianpincheira5211
    @cristianpincheira5211 5 лет назад +3

    Thanks for sahring. Short and direct

  • @makaratal9234
    @makaratal9234 6 лет назад +1

    Thanks for your sharing, I can say it is very wonderful.

  • @Luke-cu5xe
    @Luke-cu5xe 11 месяцев назад

    you saved my life with this vid

  • @KDubberley
    @KDubberley 4 года назад

    Wonderful explanation!

  • @edwincoleman6436
    @edwincoleman6436 3 года назад

    Thanks so much. This really helped

  • @takesuretozooneyi4836
    @takesuretozooneyi4836 5 лет назад

    Really useful. How do you avoid losing labels when using the collapse command?

    • @sebastianwaiecon
      @sebastianwaiecon  5 лет назад

      I'm not aware of a quick way, but I did find an article discussing this: www.stata.com/support/faqs/data-management/keeping-same-variable-with-collapse/

    • @takesuretozooneyi4836
      @takesuretozooneyi4836 5 лет назад

      @@sebastianwaiecon thanx a lot

  • @Chillypuwn
    @Chillypuwn 5 лет назад

    Very helpful. Is there any way to generate a new variable, so it does not erase the old data?

  • @evergreenbella
    @evergreenbella 3 года назад

    Thank you for sharing. One question, how can we keep other variables after collapsing??

    • @sebastianwaiecon
      @sebastianwaiecon  3 года назад +1

      You can keep as many variables as you want - just keep listing them in the command like I did in the video.

    • @evergreenbella
      @evergreenbella 3 года назад

      @@sebastianwaiecon Thank you for your answer! But after collapsing, only affected variables exist. I want other variables and collapsed variables all together.

    • @sebastianwaiecon
      @sebastianwaiecon  3 года назад +1

      When you collapse, you only get the collapsed variables and the variables you used to divide up the data. It's impossible to get non-collapsed variables to come along because they are tied to the observations in the original dataset, which no longer exists.

    • @evergreenbella
      @evergreenbella 3 года назад

      @@sebastianwaiecon Exactly! Then, there is only one way, which is merging the two datasets (collapsed var dataset and previous dataset) to have all the variables. Is that correct?

    • @jackgandhi
      @jackgandhi 3 года назад +1

      @@evergreenbella I'm not sure why you'd want to do that. Is the reason you couldn't collapse them that they are string variables? If any of the collapsed categories has any variation in the strings, merging still won't work. If not, you can just include them in the "by" statement.

  • @sanchezmayurinmarvinbecker4830
    @sanchezmayurinmarvinbecker4830 4 года назад

    Hello, I would like to ask a question. How can i generate a new basadate to have the percent of men by educcategory using collapse?

    • @sebastianwaiecon
      @sebastianwaiecon  4 года назад

      Percent is one of the operations you can do with collapse. See the manual for details: www.stata.com/manuals13/dcollapse.pdf

  • @dinobrown5956
    @dinobrown5956 3 года назад

    Great Video. How do you restore your previous data? I tried using "restore" after "preserve" but got this: "nothing to restore". Kindly help

    • @sebastianwaiecon
      @sebastianwaiecon  3 года назад

      If I want to go back, I just reload the original dataset. Just make sure to not save over the original data.

  • @kigakiku2011
    @kigakiku2011 5 лет назад

    weird. you're collapsing by a string, but my Stata returns a type mismatch error when I try to do the same

    • @kigakiku2011
      @kigakiku2011 5 лет назад

      nevermind, it's because I was trying to get it to count a string variable. I still can't believe the built-in functions of Stata can't handle basic counting of strings. ridiculous. might as well be using Excel.

    • @sebastianwaiecon
      @sebastianwaiecon  5 лет назад

      You might want to check out my video on categorical data for better handling of strings (ruclips.net/video/QN7u-ZBHqic/видео.html).

  • @WisdomThroughGod
    @WisdomThroughGod 4 года назад

    Does anyone know how to run a regression with regards to a specific part of a variable? ex my variable is sex but I want a regression of wages on females and not on men.

  • @RavindraMulye
    @RavindraMulye 2 года назад

    Is there a way to resolve stata r(950) error...