一个变量的值相对于另一个变量的唯一值的直方图

Histogram of a value for a variable over unique values of another variable

我在 Stata 中有一个包含 203 行和 2 列的数据集。这是一些行:

Voting Bidvalue 
  0       720
  1       15
  0       120
  0       960
  1       30
  1       400
  0       60
  0       960
  0       240

有八种不同的出价,包括 15、30、60、120、240、360、480、720。对于每个出价,我们可以在投票栏中找到 1 和 0 的数量。详细信息截图如下

我想找到一个直方图,其中 x 轴是 8 个出价,y 轴是投票栏中 1 的数量。

以下对我有用:

graph bar (count) Voting, over(Bidvalue)

histogram Bidvalue if Voting == 1 , freq 

是问题的答案。您更有可能想要更像

的东西
egen Toshow = group(Bidvalue), label 
label var Toshow "Bidvalue" 
histogram Toshow if Voting == 1, xla(1/8, valuelabel) discrete freq