No video

Collapsing Data in Stata

  Рет қаралды 39,034

SebastianWaiEcon

SebastianWaiEcon

Күн бұрын

Пікірлер: 30
@cristianpincheira5211
@cristianpincheira5211 5 жыл бұрын
Thanks for sahring. Short and direct
@makaratal9234
@makaratal9234 6 жыл бұрын
Thanks for your sharing, I can say it is very wonderful.
@SB-ez7wp
@SB-ez7wp 5 жыл бұрын
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 жыл бұрын
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 жыл бұрын
Thank you. I was so worried about my homework and this helped me a lot.
@KDubberley
@KDubberley 4 жыл бұрын
Wonderful explanation!
@Luke-cu5xe
@Luke-cu5xe 9 ай бұрын
you saved my life with this vid
@edwincoleman6436
@edwincoleman6436 3 жыл бұрын
Thanks so much. This really helped
@Chillypuwn
@Chillypuwn 5 жыл бұрын
Very helpful. Is there any way to generate a new variable, so it does not erase the old data?
@sebastianwaiecon
@sebastianwaiecon 5 жыл бұрын
You might want to look into the egen command.
@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
@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
@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.
@evergreenbella
@evergreenbella 3 жыл бұрын
Thank you for sharing. One question, how can we keep other variables after collapsing??
@sebastianwaiecon
@sebastianwaiecon 3 жыл бұрын
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 жыл бұрын
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 жыл бұрын
@@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.
@WisdomThroughGod
@WisdomThroughGod 3 жыл бұрын
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.
@sebastianwaiecon
@sebastianwaiecon 3 жыл бұрын
See my video on categorical data.
@RavindraMulye
@RavindraMulye 2 жыл бұрын
Is there a way to resolve stata r(950) error...
@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 (kzbin.info/www/bejne/h3-apmCQd62kn8U).
Difference in Differences Estimation in Stata
6:58
SebastianWaiEcon
Рет қаралды 202 М.
Cleaning Data in Stata
22:42
Alan Neustadtl
Рет қаралды 98 М.
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 4,2 МЛН
王子原来是假正经#艾莎
00:39
在逃的公主
Рет қаралды 24 МЛН
The Joker kisses Harley Quinn underwater!#Harley Quinn #joker
00:49
Harley Quinn with the Joker
Рет қаралды 38 МЛН
Introduction to Programming Loops in Stata
17:25
Mike Jonas Econometrics
Рет қаралды 18 М.
Fixed Effects in Stata
13:41
SebastianWaiEcon
Рет қаралды 211 М.
Data management: How to label the values of categorical variables
2:36
Tables in Stata with estout
11:40
SebastianWaiEcon
Рет қаралды 127 М.
Categorical Variables in Stata
7:56
SebastianWaiEcon
Рет қаралды 136 М.
Aggregating Data by Subgroups in STATA
7:16
David Braudt
Рет қаралды 66 М.
Panel Data Models in Stata
15:57
econometricsacademy
Рет қаралды 495 М.
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 4,2 МЛН