Hi all,
I am performing the following loop:
Now: the local recall consists of 3 names: dummy_2 dummy_3 dummy_4. They are necessary since each of the databases in the loop are called after these names as you can see from:
Now, dummy_2, dummy_3 and dummy_4 are not variables that appear in such databases (the databases are composed by 3 variables: av_t, mean_avt and rescaled_year). I use twoway connected to such databases but am forced to label the legend with dummy_2 dummy_3 and dummy_4 (label(3 "AV_t `agg' `rec'")). What if I would like to put instead of
something that gives me: "General Recalls" instead of dummy_2, "Recalls Calss I" instead of dummy_3 and "Recalls Class II" instead of dummy_4 in the graph? (i.e. renaming the content of the local recall which contains names that are not variables, without changing the name in the next iteration of the loop).
Thank you very much
I am performing the following loop:
Code:
foreach rec of local recall { tokenize `rec' local endog_1 "General Recalls" // dummy_1 = withdrawns, dummy_2 = recalls, dummy_3 = recalled_class_one, dummy_4 = recalled_class_two local endog_2 "Recalls Class I" local endog_3 "Recalls Class II" local aggr "product firm atc2" foreach agg of local aggr { use "/Users/federiconutarelli/Desktop/PhD/Lavoro_Riccaboni/DATi_USA/Pharma_project_2019 /abnormal_values/demeaned_DBs/stacked_mean_`agg'_`rec'.dta", clear collapse (mean) mean_avt var_avt, by(rescaled) gen lower = mean_avt - 1.96*(sqrt(var_avt)/11) gen higher = mean_avt + 1.96*(sqrt(var_avt)/11) drop if rescaled ==. local `1' "`endog_1'" local `2' "`endog_2'" local `3' "`endog_3'" *Grafico: twoway (connected lower higher mean_avt rescaled,lpattern(solid)), legend(label(1 "Lower C.I.") label(2 "Upper C.I.")label(3 "AV_t `agg' `rec'")) yline(0,lcolor(black)) xline(0,lwidth(thin) lpattern(shortdash)) note("Recall Year = 0") ytitle(abnormal value) xtitle(Year) xlabel(-8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11) name(pre_post_gr_`agg'_`rec', replace) } }
Code:
use "/Users/federiconutarelli/Desktop/PhD/Lavoro_Riccaboni/DATi_USA/Pharma_project_2019 /abnormal_values/demeaned_DBs/stacked_mean_`agg'_`rec'.dta", clear
Code:
label(3 "AV_t `agg' `rec'")
Thank you very much
Comment