Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: input statement inside a while loop

From   Ricardo Ovaldia <>
To   Statalist <>
Subject   st: input statement inside a while loop
Date   Thu, 8 Jul 2010 09:44:16 -0700 (PDT)

I am trying to create a data set inside a -while- loop but it keeps failing. I think that the -end- confuses Stata. 
Here is a simplified version:
local i 1
	while `i'<=10 {
		set obs 100
		gen x=uniform()
		sum x
		input str5 lines1
                  save temp`i', replace
		local i=`i'+1

. local i 1

.         while `i'<=10 {
  2.                 clear
  3.                 set obs 100
  4.                 gen x=uniform()
  5.                 sum x
  6.                 clear
  7.                 input str5 lines1
  8.                         "rec"
  9.                         "dat"
 10.                 end

end of do-file

If I take out the -input- command it works. Any ideas?

Thank you,

Ricardo Ovaldia, MS
Oklahoma City, OK

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index