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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: RE: Difficulties iterating over a do-file within a foreach loop


From   Michael Housman <mhousman@evolvondemand.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Difficulties iterating over a do-file within a foreach loop
Date   Tue, 12 Jun 2012 23:50:23 +0000

Hi folks,

Long time listener, first time caller.  I was wondering if you guys could help me with something that I'm trying to do.

I've developed code that engages in a long, involved analysis of different performance metrics that we've collecting for employees.  For example, we want to look at things like schedule adherence, quality assurance, absenteeism, customer satisfaction, etc.

What I'd like to do is use a foreach statement and then run a loop that will select a metric, call a certain do-file, run the code in that do-file, and then select another metric do this all over again until we've gotten through each of the metrics.  Here's an idea of what I have in mind:

foreach metric in schedule_adherence quality_assurance absenteeism customer_satisfaction {
              do "C:\Filepath\Do File.do"
}

The problem that I've run into is that this will work exactly once.  It select the first metric, runs the do-file, and then the program ends once it reaches the end of the do-file.

Has anyone run into this problem before?  Is there something that I'm doing wrong?  Perhaps this has something to do with the fact that there's a "clear" command at the top of the do-file that it calls before it imports a dataset?

Thanks in advance for your help!

Michael




*
*   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