I am not sure whether the following code works best for the purpose. Based on my data, it takes around two days to run from 2010-2019. I also intend to run data since 1990s, so it may take several days. I think it is a bit long.
If there is a better way to save time, please let me know and thank you so much.
gen relative_FB_all = .
gen relative_Forecast_horizon_all = .
gen relative_dayElap_all = .
gen relative_forecast_frequency_all = .
gen relative_firm_specific_all = .
gen relative_generic_all = .
gen relative_cos_followed_all = .
gen relative_indus_followed_all = .
gen relative_analyst_broke_all = .
destring gvkey, replace
levelsof fiscal_year, local(years)
foreach year of local years {
levelsof gvkey if fiscal_year == `year', local(companies)
foreach company of local companies {
levelsof analys if fiscal_year ==`year' & gvkey==`company', local(analysts)
foreach analyst of local analysts {
su forecast_bias ///
if analys!=`analyst' & fiscal_year==`year' & gvkey==`company'
replace relative_FB_all=r(mean) ///
if analys!=`analyst' & fiscal_year==`year' & gvkey==`company'
di `year'
di `company'
di `analyst'
}
}
}
Related Posts with simplified code
Probably beginner question: How to format monthly datesHi there, I am new to Stata and I started last week as a total newbie. What I want to do is to che…
Empty cells in some imputations of multiply imputed dataI have a data set that some colleagues and I need to do a survival analysis on. The outcome is time …
Do I need to add main effect in a regression model with a Difference value between two variables?Hi, Here is my regression model: regress y x1 x2 x3_x4; /* x3_x4 = x3 - x4 */ Do I need to add x3…
putpdf image errorAfter a logit, I am doing Code: lroc graph export "$charts\roc_y_1_x_`k'.png", replace putpdf imag…
Where STATA is storing the loading factors ( Factor analysis using GSEM)Hi guys, I used "gsem" commend and "predict, latent" to estimate factor scores and the factors scor…
Subscribe to:
Post Comments (Atom)
0 Response to simplified code
Post a Comment