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: loop in stata


From   fernando andrade <fandrade.stat@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: loop in stata
Date   Thu, 11 Aug 2011 15:06:20 -0400

Hello
I am trying to make a simple loop in stata but i cannot figure out how to.
i have two sets of variables let's say:
set1: a b c ...m
set2: z y x...n

i want to make a loop to run the tabs
tab a z
tab b y
tab c x
.
.
.
tab m n

i tried
foreach X in a b c... m{
foreach Y in z y x... n{
tab `X' `Y',m
}
}

the loop gave me all the posible combinatios between the two sets of
variables. Is there a way to make a loop that tabs only a with z, b
with y and so on
thank you.
Fernando
*
*   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