Hi everyone,
I don't really get why the first one does not work while the second does.
Can you explain me the different uses of gen and egen?
I also don't get mean [var] vs mean (var) .
Thank you so much and sorry for the very dummy question,
I have just started to study Stata autonomously and I get lost on very little and stupid stuffs..
.
.
.
.
So,
I've generated the variable "wpop" in this way:
gen wpop = populism*votes
Which is the level of populism for every national party ""weighted"" on its consensus at last election
Than I want to calculate the average wpop for each country.
1) bys country_id: gen pop_country = mean wpop //// why it does not work? error: invalid 'wpop' ///
2) mean wpop, over (country_id)
by country_id: egen pop_country = mean(wpop) //// this works but I do not actually get why and how does it work.
Thank you!
Silvia
P.S.
I know this is not a good way to measure countries' level of populism dw
I don't really get why the first one does not work while the second does.
Can you explain me the different uses of gen and egen?
I also don't get mean [var] vs mean (var) .
Thank you so much and sorry for the very dummy question,
I have just started to study Stata autonomously and I get lost on very little and stupid stuffs..
.
.
.
.
So,
I've generated the variable "wpop" in this way:
gen wpop = populism*votes
Which is the level of populism for every national party ""weighted"" on its consensus at last election
Than I want to calculate the average wpop for each country.
1) bys country_id: gen pop_country = mean wpop //// why it does not work? error: invalid 'wpop' ///
2) mean wpop, over (country_id)
by country_id: egen pop_country = mean(wpop) //// this works but I do not actually get why and how does it work.
Thank you!
Silvia
P.S.
I know this is not a good way to measure countries' level of populism dw
Comment