2014-06-16 159 views
0

我有一系列的交易,每个交易表明有多少单位被购买。例如,我有Stata:如何重复观察?

  • 芽光3个单位每盎司30美分
  • 米勒灯2个单位每盎司23美分

我想复制芽光3倍和米勒光2次:

  • 芽光1个单元每盎司30美分
  • 芽光1个单元每盎司
  • 美分
  • 芽光1个单元每盎司30美分
  • 米勒灯1个单元每盎司23美分
  • 米勒灯1个单元每盎司

23美分换句话说,我需要创建任意数量的单个购买如我的某一列中指出的那样进行了多少次购买。

我该怎么做?欣赏任何输入。

+1

这个问题似乎离题了这个网站。请阅读http://stackoverflow.com/help/on-topic。 'help expand'应该可以解决你的问题。 –

+0

同意这不适用于SO。询问关于Statalist的更多问题。 –

+0

这非常有帮助。非常感谢! – Olga

回答

1

有一个命令那么做。

expand

说明

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. 
+1

@Roberto Ferrer 2014年的评论很有帮助,但在Stata中,“expand”是命令,而不是函数。 –