Hi there, I would like to understand more on the condition command
I have read Prof Cox article on Stata Journal regarding the cond and used stata help, youtube.
However I still have some questions
Code - sugessted by one of the users (with thanks for a separate problem)
bys IDno: egen last_surgical=max(cond( surgicalindex==1,admidate,.))
Question A :
As far as I know after reading the above sources, statahelp presenst the command as:
cond(x,a,b[,c]) -
Where one defines the x, A = IF x is true and non missing, B = X is false and nonmissing, C = if x is missing - as does Nick Cox Paper.
The above I understand, however when one reads the command highlighted in red
1. I understand that a newvariable is created (egen last_surgical)
2. One tells stata to take the Max admidate if surgicalindex ==1
However, (which is where I need help ) ---> it seems that if this is the case the explanation of cond by Stata is no longer valid (see Question A) .... is this the case?
Any help explaining this ?
Note: Surgicalindex is a binary variable which is 1 or 0
Admidate: Date of admission into hospital
I have read Prof Cox article on Stata Journal regarding the cond and used stata help, youtube.
However I still have some questions
Code - sugessted by one of the users (with thanks for a separate problem)
bys IDno: egen last_surgical=max(cond( surgicalindex==1,admidate,.))
Question A :
As far as I know after reading the above sources, statahelp presenst the command as:
cond(x,a,b[,c]) -
Where one defines the x, A = IF x is true and non missing, B = X is false and nonmissing, C = if x is missing - as does Nick Cox Paper.
The above I understand, however when one reads the command highlighted in red
1. I understand that a newvariable is created (egen last_surgical)
2. One tells stata to take the Max admidate if surgicalindex ==1
However, (which is where I need help ) ---> it seems that if this is the case the explanation of cond by Stata is no longer valid (see Question A) .... is this the case?
Any help explaining this ?
Note: Surgicalindex is a binary variable which is 1 or 0
Admidate: Date of admission into hospital
Comment