Hello,
I'm sure this is a function but I'm having trouble finding it --
I'm trying to make a loop that behaves differently for each observation depending on the value for one of the variables.
I have this command right now,
My variable, start_of_symptoms, ranges from 1 to 21. I want to create a loop that can go through all the values of start_of_symptoms and add up the ind_`f'_w* variables accordingly.
I was trying to do this,
But I quickly realized you can't use the replace command like that.
Is there an easy way to set this up?
Thank you,
Jon
I'm sure this is a function but I'm having trouble finding it --
I'm trying to make a loop that behaves differently for each observation depending on the value for one of the variables.
I have this command right now,
Code:
foreach f in Allergy_Envir Allergy_Skin Allergy_Other Asthma Psoriasis Thyroiditis T1Diabetes Uveitis DownSyndrome{
egen `f'_sensitivity = rowtotal(ind_`f'_w1 - ind_`f'_w5) if start_of_symptoms == 5
I was trying to do this,
Code:
foreach f in Allergy_Envir Allergy_Skin Allergy_Other Asthma Psoriasis Thyroiditis T1Diabetes Uveitis DownSyndrome{
foreach w in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21{
replace `f'_sensitivity = rowtotal(ind_`f'_w1 - ind_`f'_w`w') if start_of_symptoms == `w'
Is there an easy way to set this up?
Thank you,
Jon

Comment