# How to reproduce the data format in the picture into mathematica？

In order to study the relationship between an endemic disease in a certain place and the health habits of local residents (health habits are divided into good and not good enough), a medical team randomly investigated 100 cases of the disease (called case group), and 100 people (called control group) in the population without the disease, and obtained the following data:（The data is in the following picture）

How to reproduce the data format in the picture into mathematica. In other words, if the operation makes the table data in the picture displayed in mathematica?

How to add total column and total line? See the figure below.The final effect is as follows

\$Version

"13.2.0 for Mac OS X x86 (64-bit) (November 18, 2022)"

Clear["Global*"]

data1 = {{"", "not good enough", "good"}, {"case group", 40,
60}, {"control group", 10, 90}};

Grid[data1, Frame -> All, ItemSize -> 10]


data2 = {{"study groups", "health habits",
SpanFromLeft}, {SpanFromAbove, "not good enough",
"good"}, {"case group", 40, 60}, {"control group", 10, 90}};

Grid[data2, Frame -> All, ItemSize -> 10,
Alignment -> {Center, Center}]


• TIL: SpanFromLeft and SpanFromAbove! Even though they are right and center in Grid`'s documentation, I never noticed them. +1 Jan 31 at 0:05
• How to add total column and total line? Jan 31 at 0:07
• data1 = {{"", "not good enough", "good", "total"}, {"case group", 40, 60, 100}, {"control group", 10, 90, 100}, {"total", 50, 150, 200}}; Grid[data1, Frame -> All, ItemSize -> 10] Jan 31 at 0:25
• Add a total row and column at the bottom and right of the table. Can I automatically calculate the sum of the corresponding row and column data? Jan 31 at 0:26