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
Estimation via SURE model(Seemingly Unrelated Equation Models) dependent variable delta_cash short term debt long term debt intercept working ca…
Can not use -suest- for margins after probit or regressDear Statalists, I am trying to estimate for several models (using -probit- or -regress-) and hope …
Testing statistical difference in coefficients after ppml estimation of gravity modelDear all, I am running a PPML regression for a trade gravity model using bilateral trade flows and …
Help running a bootstrap within a forvalues loopDear all, Apologies if this is very basic, however I have spent the better part of a day going thro…
Moderated Mediation on archival longitudinal data (with no latent variables)Hi, I have organizational data for 5 years (archival panel with no latent variables). I am strugglin…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with calculating functions over subgroups
Post a Comment