From: "Nick Cox" <[email protected]>
Reply-To: [email protected]
To: <[email protected]>
Subject: st: RE: Automating a batch of -insheet- and -save- in a do-file
Date: Fri, 16 Dec 2005 13:57:09 -0000
forval i = 1/87 {
insheet using filename`i'.txt, clear
save c:\DATA\filename`i'.dta", replace
}
Nick
[email protected]
b. water
> Stata 8.2, Windows XP Pro SP2
>
> I am creating a simple do-file that essentially perform insheet using
> filename.txt where filename is labelled sequentially from 1-87 e.g.
> filename1, filename2, filename3, etc... After the file has
> been insheeted
> and processed, I want it saved as filename.dta where the
> filename.dta will
> be the corresponding text filename i.e. filename1.dta for
> filename1.txt,
> filename2.dta for filename2.txt, etc... up to filename87.dta for
> filename87.txt. Is there a way to shorten what I am trying to
> achieve rather
> than copy paste 87 times in the text editor? Below is a
> truncated list what
> I am trying to do.
>
> clear
> insheet using filename1.txt
> .
> .(some 'do' routine)
> .
> save "C:\DATA\filename1.dta", replace
> clear
> insheet using filename2.txt
> .
> .
> .
> save "C:\DATA\filename2.dta", replace
> clear
> .
> .
> .
> clear
> insheet using filename87.txt
> .
> .
> .
> save "C:\DATA\filename87.dta", replace
>
> Again, thank you all for advise and help.
*
* 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/
_________________________________________________________________