Hello Stata users,
I am trying to generate and export summary statistic table using dtable command.
First of all, my data looks something like:
.. and so on. It is panel data: country x year x industry.
I would like to generate two separate summary statistics of variables "jcr" and "jdr" by (quantile group) & by (quantile group*ind).
So, I began with the following code:
However, the output says:
and there weren't any table, but it was written:
Could someone help me with this issue and get the desired table, please?
Thanks so much!
I am trying to generate and export summary statistic table using dtable command.
First of all, my data looks something like:
country | year | ind | LP_quantile | jcr | jdr |
A | 2016 | 3 | 0-10 | 0.1 | 0.2 |
A | 2016 | 3 | 10-40 | 0.1 | 0.1 |
A | 2016 | 3 | 40-60 | 0.1 | 0.1 |
A | 2016 | 3 | 60-90 | 0.1 | 0.1 |
A | 2016 | 3 | 90-100 | 0.1 | 0.1 |
A | 2016 | 6 | 0-10 | 0.2 | 0.2 |
A | 2016 | 6 | 10-40 | 0.2 | 0.2 |
A | 2016 | 6 | 40-60 | 0.2 | 0.3 |
A | 2016 | 6 | 60-90 | 0.3 | 0.3 |
A | 2016 | 6 | 90-100 | 0.4 | 0.4 |
A | 2017 | 3 | 0-10 | 0.4 | 0.5 |
I would like to generate two separate summary statistics of variables "jcr" and "jdr" by (quantile group) & by (quantile group*ind).
So, I began with the following code:
Code:
local vars_sumstat jcr jdr local varlist `vars_sumstat' local quant LP_quantile collect clear dtable , /// sample( , stat(freq)) /// cont(`varlist', stat(p1 p5 p10 p25 p50 p75 p90 p95 p99)) /// by(`quant') collect label levels result frequency "N", modify foreach n of numlist 1 5 10 25 50 75 90 95 99 { collect remap result = percentile, fortags(result[p`n']) collect label levels percentile p`n' "`n'%", modify } collect label dim percentile "Percentiles", modify collect style header percentile, title(label) collect style header result, title(hide) level(label) collect style cell result[frequency] percentile, nformat(%3.0f) collect style cell result[mean], nformat(%5.2f) collect style cell percentile#cell_type[column-header], border(bottom, color(black)) collect style header var, title(hide) level(hide) foreach v of varlist `varlist' { collect layout (var[`v']#quant) (result[frequency mean min max] percentile[p1 p5 p10 p25 p50 p75 p90 p95 p99]) collect title "Distribution of `v' by quantile group" collect export "sum_stat.xlsx", sheet("`v'", replace) modify }
Code:
(dimension quant not found) (level max of dimension result not found) (level min of dimension result not found) Collection: DTable Rows: var[jcr]#quant Columns: result[frequency mean min max] percentile[p1 p5 p10 p25 p50 p75 p90 p95 p99] Your layout specification does not uniquely match any items. One or more of the following dimensions might help uniquely match items: colname, LP_quantile, statcmd, var. (collection DTable exported to file
Your layout specification does not uniquely match any items. One or more of the following dimensions might help uniquely match items: colname, LP_quantile, statcmd, var. |
Thanks so much!
Comment