Dear all, I am dealing with a micro data where I have around 100000 observations from 81 cities about one variable (let's call it as X) which is given in Likert scale (1 to 5, integer ofcourse). Using egen command, I wanted STATA to find the average of X for each city and I wrote the following command:
egen Xcity = mean(X), by(city)
tab Xcity
I am able to get the average values of X for each city. However, I wanted to be sure that the command works correctly. Therefore, I checked the results for few cities using the original data in Excel and my results in Excel are always different than what Stata calculates. I even checked the data in Excel with Stata Stata Data Editor. They both have the same data but different mean values. How is that possible? What is the mistake that I am doing here or what am I missing? I appreciate your help. Thanks.
Related Posts with egen and mean help needed
Calculate odds ratio from linear regression coefficient with binary dependt variable?Hello everyone! I have a multiple linear regression model with, among others, a categorical variabl…
A question about longtitudinal data analysis: what is the difference between xt..., pa vs. xt..., fe ?Hello , I am a master student and start to learn the panel data, it took me a week to read all the s…
Comparing models in Latent Class analysisI have stored the estimates for a 2-class, 3-class, 4-class and 5-class model. Now I would like to c…
Endogenous control variables in nonlinear regressionDear Statlisters, I am sorry in advance for the length of this question, I found that a little conte…
If statement with stringDear everyone, I hope you are doing well. I exported a document from Excel into Stata. One of the c…
Subscribe to:
Post Comments (Atom)
0 Response to egen and mean help needed
Post a Comment