Dear Statalist,
I wish to generate variable "a" on basis of variable "a" (data generated within script) and "b" (cont.data) and scalar "c" and "d"
time_id a b
1 . 1
2 . 0
3 . 2.8
4 . 0.325
5 . 0
6 . 0
7 . 0.73
8 . 0
9 . 1.6
10 . 0
scalar c 0.01
scalar d 1
generate a = 0
if time_id>1 local i = a[_n-1] + b - c
if `i' < d {
replace a = `i'
}
else if `i' > d {
replace a = d
}
else if `i' < 0 {
replace a = 0
}
It appears to be some problem with the program which perhaps is related to how I conditioned the local macro.
Any suggestions?
I wish to generate variable "a" on basis of variable "a" (data generated within script) and "b" (cont.data) and scalar "c" and "d"
time_id a b
1 . 1
2 . 0
3 . 2.8
4 . 0.325
5 . 0
6 . 0
7 . 0.73
8 . 0
9 . 1.6
10 . 0
scalar c 0.01
scalar d 1
generate a = 0
if time_id>1 local i = a[_n-1] + b - c
if `i' < d {
replace a = `i'
}
else if `i' > d {
replace a = d
}
else if `i' < 0 {
replace a = 0
}
It appears to be some problem with the program which perhaps is related to how I conditioned the local macro.
Any suggestions?
Comment