[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: i and i-1 in forvalues command
Dear all,
I want to categorize the subjects in my dataset according to the number
of hours they work. I define say 5 kategories with kat0, kat1, kat2,...,
kat5 being the highest number of hours in each category.
Then I categorize using
gen kat = .
forvalues i = 1/5 {
replace kat = `i' if hour > kat`i-1' & hour <= kat`i'
}
the problem is I apparently cant write i-1 between ` and '
does anybody know how I can access i-1 while the loop is in state i?
thanks for your help!
best, Florian
*
* 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/