Hi,
I am having some troubles in computing functions over subgroups.
Basically, I have some financial data over a time period of 4 years for some firms and I would like to create a variable for the mean or the sum of these data by year. You can see in the attachment how my data looks like.
I tried this code:
bysort Date: egen meanPrice= mean(Price),
but it does not work.
I know that with the commad collapse it works, but then I would need to add the new variable with the old dataset and I cannot it merge it.
Could you please help me?
Thank you in advance!
Related Posts with Problem with calculating functions over subgroups
How to overlay distributions using a pie chart using StataMP 17? (plot distributions on the same graph)Dear Statalist, I hope you are well. Please, I need help on how to overlay distributions using a p…
About structural equation modellingHi, I am a doctoral student preparing a thesis on how individual values, beliefs, and attitudes affe…
Collapse all values of one string variable to one cell per groupSay I have the following data set: id var1 1 a 1 b 1 c 2 a 2 d 3 a Is there a way to collapse this…
Iterations in Poission RegressionI was running a code for negative binomial and poisson regression and the results were not convergin…
Understanding/Reading Regression Output With Categorical VariablesHello; I have experience with regression, I just haven't done it in a while and am SUPER confused a…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with calculating functions over subgroups
Post a Comment