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]

st: loop in stata

From   fernando andrade <>
To   statalist <>
Subject   st: loop in stata
Date   Thu, 11 Aug 2011 15:06:20 -0400

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

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