Hi I've got a list of dates and a condition I'm interested in --> DVT
var 2 is the date of when the patient was admitted to hospital
opdate when the patient had the operation.
Thus one can conclude if the patient had condition DVT after the patient had the operation then opdate would be > var2
Dataset found below and code used found below
Example generated by -dataex-. For more info, type help dataex
clear
input str4 var1 float var2 byte DVT float(opdateproper postopcomplication)
"date" 1202021 1 1202021 0
"" 13032022 1 13032022 0
"" 14022022 0 . 0
end
[/CODE]
------------------ copy up to and including the previous line ------------------
gen postopcomplication = 0
replace postopcomplication = 1 if DVT == 1 & opdateproper > var2
Questions:
1. Why hasn't stata replaced DVT = 1 for the opdateproper which is marked as . as this is greater than var2
2. Is there a more efficient way of doing this in terms of syntax?
var 2 is the date of when the patient was admitted to hospital
opdate when the patient had the operation.
Thus one can conclude if the patient had condition DVT after the patient had the operation then opdate would be > var2
Dataset found below and code used found below
Example generated by -dataex-. For more info, type help dataex
clear
input str4 var1 float var2 byte DVT float(opdateproper postopcomplication)
"date" 1202021 1 1202021 0
"" 13032022 1 13032022 0
"" 14022022 0 . 0
end
[/CODE]
------------------ copy up to and including the previous line ------------------
gen postopcomplication = 0
replace postopcomplication = 1 if DVT == 1 & opdateproper > var2
Questions:
1. Why hasn't stata replaced DVT = 1 for the opdateproper which is marked as . as this is greater than var2
2. Is there a more efficient way of doing this in terms of syntax?
Comment