Dear Stata users,

I want to replace the values of variable with conditions. This is the example of my data.

Code:
clear
input long ID int LOS float weight str5 caretype
7811 41 0 "4A91"
1013 9 0 "4A91"
487 7 0 "4AH2"
2172 12 0 "4A91"
147 15 0 "4AH4"
2703 7 0 "4A91"
4692 8 0 "4AR4"
7423 1 0 "4A91"
1219 13 0 "4A91"
98748 27 0 "4A91"
end
I want to replace the weight with 3 different values based on 3 conditions:
- weight = 0.8 if (18.96+15.08)/2 <= LOS <= (25.28+18.96)/2 & caretype ="4A91"
- weight = 0.8 + 0.06*(LOS - 19) if LOS > (25.28+18.96)/2 & caretype ="4A91"
- weight = 0.078*LOS if LOS < (18.96+15.08)/2 & caretype ="4A91"

Could you kindly show me how to do this?

Thank you so much