Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Inserting non blank observations multiple times


From   Eric Booth <ebooth@ppri.tamu.edu>
To   "<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Inserting non blank observations multiple times
Date   Fri, 8 Jul 2011 19:07:41 +0000

<>

Here's one approach:
****************
clear
**create fake data:
input str10(v1)
original1
original2
original3
end


**
levelsof v1, loc(o)
foreach v in `o' {
	g `v' = "`v'"
	}
keep in 1
set obs 762

forval n = 2/`=_N' {
	foreach v of varlist original* {
	  replace `v' = "new`=`n'-1'" in  `n'
	}
   }
drop v1
stack original*, into(all) clear	
****************

- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
ebooth@ppri.tamu.edu

On Jul 8, 2011, at 1:48 PM, Bryan Stuart wrote:

> I have a data set with 94 observations. After each observation, I want
> to enter 761 (non blank) observations. The new observations will be
> the same for each of the original 94 observations. I found the INSOB
> module, which can easily enter blank observations. This isn't what I
> want. I want to move from something like:
> 
> original1
> original2
> original3
> 
> to something like:
> 
> original1
> new1
> new2
> ...
> new761
> original2
> new1
> new2
> ...
> new761
> original3
> ...
> 
> Does anyone have suggestions? Thanks in advance.
> 
> Bryan Stuart
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index