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
Store coefficients/SEs for factor variables, maybe using statsbyI'm regressing something on a factor variable with many levels. I would like to save the coefficient…
Scatter PlotWhat command can I use to create a Scatter plot with regression line and line of perfect correlation…
Moderator affected by IV, in Mediation Effect on DVMy model looks like this: IV ---> Mediator1 ----> DV and Moderator 1, Moderator 2, Moderator …
Making systematic changes to set of do-filesI have a large number of do-files that I would like to run by systematically changing parts of the c…
Insignificant and unexpected coefficients in fe model, especially with year dummiesHI Statalisters, This is my first time using the forum so apologies for any mistakes in the way I a…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with calculating functions over subgroups
Post a Comment