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, is already up and running.

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

Re: st: Looping or macro needed??? - Followup question

From   Sarah Elizabeth Edgington <>
Subject   Re: st: Looping or macro needed??? - Followup question
Date   Fri, 03 Jun 2011 08:30:19 -0700

The clear command is not wiping out the log statement. Since you don't provide info on what you actually did or in what way it isn't working I can't give you any guidance on what is actually going wrong with what you've done.

Whether you make one log or eight is entirely a matter of personal preference. If you wanted to you could even do both by using the name option on one of the logs (see -help log- for more info on that).

Let's assume you want to do eight separate logs. Your setup might look like this:

foreach s in aaa bbb ccc ddd eee fff ggg hhh {
       log using "P:\ProjectName \logs\logforMat070809_`s'.log", replace
       use  "P:\ProjectName \Mat070809_`s'.dta, clear


       log close


At 07:28 AM 6/3/2011, Jennifer A Hoff wrote:
OK I got the loop working  - Thanks Nick!

Next question is how to deal with making a log file

Do I put the log statement outside the loop and make one log file
containing results of all 8 datasets?
Or do I put the log command inside of the loop and make a log file for

Neither seems to be working on my first attempts.
Is the clear command wiping out the log statement?

foreach s in aaa bbb ccc ddd eee fff ggg hhh {
       use  "P:\ProjectName \Mat070809_`s'.dta, clear

Jennifer Hoff Lindquist
Health Services Research and Development
Mailing Address:
VA Medical Center
508 Fulton Street (152)
Durham, NC 27705
(919) 286-0411 Ext. 4054 (New as of 5/18/09)

*   For searches and help try:

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