Bookmark and Share

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


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

st: foreach over local or global macro


From   "Jennifer S. Earl" <[email protected]>
To   [email protected]
Subject   st: foreach over local or global macro
Date   Thu, 14 Jul 2011 13:19:43 -0700

Hi folks,

Another foreach question. I am trying to loop over a list of letters a-z and print out results for each letter, but my foreach call is not working:

foreach A of global c(alpha) {

	preserve
	drop if letter!=`A'

	* open coder specific log
	log using "`A'_module1_cleaning.log" , append

	* prints out the frequencies for each type of error
	forvalues i = 1(1)9 {
		tab mod1_err00`i' if mod1_err00`i'!="0" , missing
	}

	forvalues i = 10(1)99 {
		tab mod1_err0`i' if mod1_err0`i'!="0" , missing
	}

	restore
	log close
}

I have also tried it with "foreach A of local c(alpha) {" and many other iterations. What am I missing here? I searched a lot of pages and I have tried a bunch of suggestions but there is obviously something more basic that I missing.

Thanks,

Jenn


*********************************
Jennifer Earl
Professor of Sociology
SS&MS 3129
University of California, Santa Barbara
Santa Barbara, CA  93106-9430

P: (805) 893-7471
F: (805) 893-3324
http://www.soc.ucsb.edu/faculty/earl/
*********************************
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index