Stata:如何复制观测值?

Stata:如何复制观测值?,stata,Stata,我有一系列交易,每一笔交易都表明购买了多少单位。例如,我有 Bud Light每盎司3台30美分 Miller Light 2台,每盎司23美分 我要复制Bud Light 3次和Miller Light 2次: Bud Light 1单位每盎司30美分 Bud Light 1单位每盎司30美分 Bud Light 1单位每盎司30美分 Miller Light 1单位每盎司23美分 Miller Light 1单位每盎司23美分 换句话说,我需要创建与我的一列中所示的购买数量相同的单个

我有一系列交易,每一笔交易都表明购买了多少单位。例如,我有

  • Bud Light每盎司3台30美分
  • Miller Light 2台,每盎司23美分
我要复制Bud Light 3次和Miller Light 2次:

  • Bud Light 1单位每盎司30美分
  • Bud Light 1单位每盎司30美分
  • Bud Light 1单位每盎司30美分
  • Miller Light 1单位每盎司23美分
  • Miller Light 1单位每盎司23美分
换句话说,我需要创建与我的一列中所示的购买数量相同的单个购买条目


我该怎么做?感谢您的任何意见

有一个命令正是这样做的

查看
展开

描述

expand replaces each observation in the dataset with n copies of the observation, where n is equal to the
required expression rounded to the nearest integer.  If the expression is less than 1 or equal to missing,
it is interpreted as if it were 1, and the observation is retained but not duplicated.

这个问题似乎与本网站无关。请阅读<代码>帮助展开应该可以解决您的问题。同意这不适合这样做。问更多关于Statalist的问题。这非常有帮助。非常感谢你!从2014年开始,对@Roberto Ferrer的评论进行了有益的扩展,但在Stata术语中,
expand
是一个命令,而不是一个函数。