Hi I am trying to sort through a large amount of data and narrow it down. To give a clear example, I have variables 1 through 40 with each variable representing a diagnosis.
I am using the replace if function to narrow down the diagnoses I want to keep in my future analysis. So my do file looks something like this:
replace had_bleeding=1 if diagnosis1=="nosebleeding"
replace had_bleeding=1 if diagnosis2=="nosebleeding"
and so forth...
My question is if there is a way to run the code so I can go through variables 1 through 40 quickly, like:
replace had_bleeding=1 if diagnosis1 through diagnosis40=="nosebleeding"
Is there a good way to do this in STATA? Otherwise, I have to write each one independently which is time-consuming.
Would appreciate the help, thanks.
I am using the replace if function to narrow down the diagnoses I want to keep in my future analysis. So my do file looks something like this:
replace had_bleeding=1 if diagnosis1=="nosebleeding"
replace had_bleeding=1 if diagnosis2=="nosebleeding"
and so forth...
My question is if there is a way to run the code so I can go through variables 1 through 40 quickly, like:
replace had_bleeding=1 if diagnosis1 through diagnosis40=="nosebleeding"
Is there a good way to do this in STATA? Otherwise, I have to write each one independently which is time-consuming.
Would appreciate the help, thanks.
Comment