Statalist


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

st: AW: forval with value of variable


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: forval with value of variable
Date   Wed, 11 Feb 2009 16:52:12 +0100

<> 

I guess you want something like


*************
use http://www.stata-press.com/data/r10/nlswork.dta, clear
su year, mean
forv i=`r(min)'/`r(max)'{
di in red "Now at year: " `i'
* do what you want in terms of `i'
}
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Rike
Gesendet: Mittwoch, 11. Februar 2009 16:47
An: statalist
Betreff: st: forval with value of variable

Dear all,

I want forval to loop over the (min) value of two variables. More
specifically, there is a variable called start_year and another called
end_year and what I want is something like this:

forval x = start_year / end_year  {
.
.
}

The variables have all the same value but i want to repeat the same
codes across different samples that have varying starting and ending
years. This is why I don't want to put the years in numbers as this
would create a lot more work.

Is there a way to do this?

Thanks.
*
*   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/


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index