Apart from Maarten's pertinent comments, note that in Stata this could
be done like
this, translating ? : to -cond(,)-
gen week = 1
gen dow = dow(stdate)
replace week = cond(dow < dow[_n-1], week[_n-1] + 1, week[_n-1]) in 2/L
Nick
[email protected]
Ashim Kapoor
I am having trouble with the last line of the following code : -
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gen week=1
gen dow=dow(stdate)
gen changeinweek=1 if dow< dow[_n-1]
replace week=( changeinweek==. ) ? week[_n-1] : week[_n-1]+1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
It says " invalid ? "
Could someone please tell me what I am doing wrong ? In case someone
needs details I am assigning weeks to my data.
*
* 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/