Hi,
I am trying to use loop and "if statement" together instead of "if qualifier". You can see my 2 different codes below. I used if statement in the first one, and if qualifier in the second one. I am trying to make y and order equal when mod(order)=1. (Order is from 1 to 248) I can use mod command but need to use this code (with if statement) for some other purposes.
First Code:
forvalues i=1(5)248{
if order==`i'{
replace y= `i'
}
}
Second Code:
forvalues i=1(5)248{
replace y= `i' if order==`i'
}
When I write it with if qualifier, it works. However, I did not understand why my first code did not work. (y's are all equal to 1)
Can someone help me to shed light on this issue.
Thanks in advance.
Best,
Ulas
I am trying to use loop and "if statement" together instead of "if qualifier". You can see my 2 different codes below. I used if statement in the first one, and if qualifier in the second one. I am trying to make y and order equal when mod(order)=1. (Order is from 1 to 248) I can use mod command but need to use this code (with if statement) for some other purposes.
First Code:
forvalues i=1(5)248{
if order==`i'{
replace y= `i'
}
}
Second Code:
forvalues i=1(5)248{
replace y= `i' if order==`i'
}
When I write it with if qualifier, it works. However, I did not understand why my first code did not work. (y's are all equal to 1)
Can someone help me to shed light on this issue.
Thanks in advance.
Best,
Ulas
Comment