首页 > 解决方案 > 你能划分两个表的条​​目吗?

问题描述

我在 Stata 中有 2 个表格:一个显示每个州在特定离婚年份队列中离婚的父母总数,另一个显示csphycus == 2每个州和离婚年份队列中离婚父母的数量。

csphycus ==2我想要一个表格,显示每个州和每个离婚年份队列的父母百分比。所以我想划分这两个表中的计数。我该怎么做?

标签: statapercentagetabulate

解决方案


你的意思是

egen double numer = total(rdasecwt * (csphycus == 2)), by(statefip yrdivbin) 
egen double denom = total(rdasecwt), by(statefip yrdivbin) 
gen wanted = 100 * numer/denom 

你可以通过一些变化来展示它

tabdisp statefip yrdivbin, c(wanted) format(%2.1f) 

推荐阅读