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 generates the mean for each signle observations, instead of having the mean for each of the years.
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
Import all files from a folderA folder contains a lot of csv files with similar rows and columns. Without having to list all their…
Exporting results of Ttests with Unequal variancesI have a bunch of variables and I want to conduct a 2-group mean comparison test with unequal varian…
How do I save the mean as well as the confidence interval results from bootstrap in every interation and plot it in a graph? I want to save the mean value as well as the confidence interval in every iteration and plot it in …
DiD for binary outcomesHow to run the difference in difference estimates for binary outcomes? …
how to draw a bar like the picturehow to draw a bar like the picture using the following data,thanks! clear input int year double(Juni…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with calculating functions over subgroups
Post a Comment