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: foreach over local or global macro

From   "Jennifer S. Earl" <>
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) {

	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

	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.



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
*   For searches and help try:

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