Statalist


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

st: i and i-1 in forvalues command


From   Florian Wakolbinger <[email protected]>
To   [email protected]
Subject   st: i and i-1 in forvalues command
Date   Sat, 17 Jan 2009 17:37:26 +0100

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/



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