# st: Re: how to regenerate data

 From Kit Baum <[email protected]> To [email protected] Subject st: Re: how to regenerate data Date Sat, 29 Jan 2005 09:01:15 -0500

I don't think you really want to do this. If you replicate a given observation N times, that is equivalent to multiplying that observation's values by N when computing any least squares estimator (and that includes the arithmetic mean). Stata supports weights -- several kinds, but these are frequency weights. Whatever calculation you might perform on the expanded data set will be much more easily specified by saying that you want to do that calculation using frequency weights (fw) equal to the variable containing N. For example using sysuse auto:

. summ price [fw=rep78]

Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
price | 235 6151.511 2787.12 3291 15906

rep78 contains integers 1,2,3,4,5 and missing values. This is a weighted mean with cars with rep78=1 entering as is, those with rep78=2 multiplied by 2, etc. The total N is now shown as 235 = 1*2 + 2*8 +3*30 +4*18 +5*11 from tab rep78. Thus if I went to the trouble of generating a dataset in which I took each observation and replicated it rep78_i times, I would have 235 obs and could do unweighted statistics, regressions, etc. Or, much more simply, I could just use [fw=rep78]. That is what I would suggest that you do.

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html

On Jan 29, 2005, at 2:33 AM, statalist-digest wrote:

I try to do some basic stata programming but still quite lost and would
appreciate any guidance. I have a dataset like N1 N2 N3 X1 X2 X3 for each
period of time T. N is the number who answer each choice and X are
macroeconomics data. What I try to do is generate new observation according
to each N (e.g. if N1=100 generate new 100 observation) that have the same X
value for each period of time T. I have looked at foreach, forval, if
command and the archive for previous questions but still could not move on
and would appreciate any guidance.
```*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```