Stata Command Modifiers--if, in, and by/bysort

Поделиться
HTML-код
  • Опубликовано: 12 сен 2013
  • A tutorial onhow to use the Stata command modifiers -if-, -in-, -by-, and -bysort-.
  • ХоббиХобби

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

  • @laurenb4182
    @laurenb4182 6 лет назад

    I don't have you as a professor anymore and you're still helping me learn-- thank you!!

  • @athenaiximena8967
    @athenaiximena8967 7 лет назад

    Muchas gracias!! Eres el mejor :)

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

    thank you so much Alan, I wish you the best...to Rome with love

  • @kannank7265
    @kannank7265 10 лет назад

    thank you very much for uploading this video. This was very helpful

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

    Excellent video. I was trying to do the equivalent of bysorting in R and it ended up being a lot quicker to just load it in Stata and clean it with the bysort function, then move back to R for spatial analysis. Thank you!

  • @han.c0401
    @han.c0401 5 лет назад

    Great tutorial, thanks!

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

    Thank you!

  • @intellectamit
    @intellectamit 8 лет назад +1

    You are my new hero :)

    • @smilex3
      @smilex3  8 лет назад

      +Amit Kumar Thank you! I am glad you found it useful. If you have suggestions about new videos about programming in Stata, please let me know.

    • @intellectamit
      @intellectamit 8 лет назад

      Sure Alan. Thanks.

  • @leeshingshyan
    @leeshingshyan 7 лет назад

    Hi Alan, Thank you for your video, its very helpful! Just wondering though, would the logical operators, eg & or | functions work if i typed it out in words? Example, instead of saying "something" if A & B, would it work if i used "something" if A and B?

    • @smilex3
      @smilex3  7 лет назад

      I have ti comments. First, you should just try it! The command window is a great place to non-destructively experiment with different commands and options.
      Unfortunately, what you propose will not work. Second, Stata like all programming languages does what it does with great precision and pays no attention my (or your) desires! This is why the online help files are so important.

  • @zyanyishs
    @zyanyishs 7 лет назад +1

    Hello, I was wondering if you could help me with a problem. I am trying studying groups of different sizes, and I want to count how many cases in a group do I have in a specific category. For example, If i have 5 individuals in the group, how many of them have low levels of sugar. Thanks!

    • @smilex3
      @smilex3  7 лет назад +1

      Carolina, I am uncertain exactly what you are asking. What defines a group? Maybe the following code will help you.
      sysuse auto, clear
      summ mpg, meanonly
      levelsof rep78, local(levels)
      foreach num of numlist `levels' {
      count if rep78==`num' & mpg< r(mean)
      }
      First, I estimate the mean of mpg. Second, I identify the unique values of rep78. Third, I set up a loop. Fourth, within the loop I count the number of cases at each level of rep78 (analogous to your "group") that have values less than the mean of mpg.
      Does this give you a way forward with your problem?
      Best,
      Alan

  • @myrahahmad
    @myrahahmad 6 лет назад

    Using bysort is there a way to see medians or p values?

    • @smilex3
      @smilex3  6 лет назад

      Can you clarify what you are trying to accomplish? The bysort prefix simply determines how a dataset is sorted to analyze things by groups. For example, "what is the average income by age group?"

  • @descalante7492
    @descalante7492 6 лет назад

    How do i summarize variables and only show mean and standard deviation and not freq or min & max

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

      How about:
      sysuse auto, clear
      tabstat price mpg headroom, statistics(mean sd)

    • @descalante7492
      @descalante7492 6 лет назад

      Alan Neustadtl yup that worked. Tabsat variables, statistics (mean sd) columns (statistics) 👍🏼

  • @Steven5727
    @Steven5727 10 лет назад

    Hi Allen, I have an issue regarding Stata and hope that you are able to help me with that. How can I get in contact with you outside youtube (by e-mail, facebook etc.)?

    • @smilex3
      @smilex3  10 лет назад +2

      Steven, my work email address is smilex3@umd.edu. Also, the Stata listserv is a tremendous resource with many incredible Stata programmers and researchers who willingly and freely answer just about every question that is posed.
      The URL to get started is www.stata.com/statalist/. If you join, please read the FAQ before posting to understand the list etiquette and how to frame a question that has a good chance of being answered.
      The FAQ is available at www.stata.com/support/faqs/resources/statalist-faq/.
      Best,
      Alan

    • @Steven5727
      @Steven5727 10 лет назад

      Alan Neustadtl I did that, but still no reply on my question. If I do not receive a reply tomorrow, I will send you an e-mail with the same question. If that is okay with you?

    • @smilex3
      @smilex3  10 лет назад

      Steven5727 Sure...what email address did you use on Stata list?

    • @Steven5727
      @Steven5727 10 лет назад

      Alan Neustadtl krap_m@hotmail.com

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

    Please i need your help for data visualization

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

    señor no entiendo