Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Loop over all unique values of a variable


From   "Peter Dijkstra" <[email protected]>
To   [email protected]
Subject   st: Loop over all unique values of a variable
Date   Thu, 14 Feb 2008 09:46:02 +0100

Dear Statalisters,

I want to perform regressions on subsets of the data, and therefore I want to loop over all unique (numerical) values of this variable. However, using foreach or forvalues only results in a loop over the variable name!
   foreach x in strata_id {
      regress y x1 x2 if strata_id == `x'
   }
Now the regression is performed if strata_id == "strata_id".
Any help would be appreciated!

Cheers, Peter
-- 
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games! 
http://games.entertainment.web.de/de/entertainment/games/free
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index