Stata:如何根据病例对照研究的结果生成数据集?

Stata: How can I generate a dataset from the results of a case-control study?

我有以下结果想输入 Stata 和 运行 一些分析:

有没有一种方法可以在 Stata 中为这些数据生成数据集,以便有适当数量的观察,让我可以 运行 tabodds 或类似的?

也许这就是您要找的。

clear
set obs 6
gen region = word("`c(ALPHA)'", ceil(_n / 2))
bysort region : gen control = _n - 1
label define casecontrol 1 "Control" 0 "Case"
label values control casecontrol
local expandlist 708 1392 946 2086 328 996
gen exp = real(word("`expandlist'", _n))
expand exp
drop exp
tab region control

结果:

. tab region control

           |        control
    region |      Case    Control |     Total
-----------+----------------------+----------
         A |       708      1,392 |     2,100 
         B |       946      2,086 |     3,032 
         C |       328        996 |     1,324 
-----------+----------------------+----------
     Total |     1,982      4,474 |     6,456