Hi,
I am trying to program a code that goes through variables pr1-25 (procedure codes) to create a new variable that corresponds to these codes prday1-prday25 where prday contains the day of the procedure performed.
This is the code I am using
gen time_procedure=.
foreach x of numlist 1/25 {
replace time_procedure=prday`x' if i10_pr`x' == "ddd" | i10_pr`x' == "ffff"
}
The issue is that through 1-25 there might be more than one procedure with ddd or ffff codes, so I want the code to run but stop replacing the days if it encountered further procedure through 25
for example
if pr1 is ffff it replaces the day with "5" which is the value in prday1
if the same record has pr5 as ddd or ffff, it will replace the "5" with "10" which is the code in prday5
I don't want that replace to happen, is there anyway to do that?
Related Posts with Making foreach go through multiple variables but stops when one criteria is met
What statistical method would I apply?Hello. Basic information for my project is below; - RCT - Group(3); A type Exercise, B type Exercis…
How to merge two condition together in a regression?Hi all, I am running a regression using Code: reghdfe with two condition that Code: reghdfe y x i…
advanced wide to long reshapingCiao guys, My data editor displays the following: Code: country year ExpJanuary ImpJanuary ExpFebr…
ivbounds: New command to estimate treatment effects when the treatment is endogenous and misreportedDear all, Thanks to Prof Baum, a new command is now available on SSC. This new command, named -ivbo…
Replacing bilateral valuesDear all, I am trying to replace country pair value equal to other countries pai. I start presentin…
Subscribe to:
Post Comments (Atom)
0 Response to Making foreach go through multiple variables but stops when one criteria is met
Post a Comment