Hello,
I am working with the cses dataset that is all about election and voting behavior.
My goal is to generate a variable that entails different means, depending on specific countries and party belonging.
I know this sounds a bit chaotic, so let me show you an example of the code that comes closes to what I want to do:
The problem with that code is that it creates missings for all the observations that are not Germany and B3033_A. I have tried to replace the missings using code like
but the syntax is incorrect and I get an error message.
Is there any way I can replace the missings with different 'means'? Or am I copletely on the wrong track?
I am just starting out with Stata, so I am sorry if there is a very obvious answer.
Kind regards
Paula
I am working with the cses dataset that is all about election and voting behavior.
My goal is to generate a variable that entails different means, depending on specific countries and party belonging.
I know this sounds a bit chaotic, so let me show you an example of the code that comes closes to what I want to do:
Code:
egen myvar =mean(B3033_A) if B1006_NAM == "Germany"
Code:
replace myvar = mean(B3033_A) if B1006 == "France"
Is there any way I can replace the missings with different 'means'? Or am I copletely on the wrong track?
I am just starting out with Stata, so I am sorry if there is a very obvious answer.
Kind regards
Paula
Comment