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
Difference between "fracreg" and "glm family(binomial) link(logit)"Hello everyone, I would be eager to know the difference between commands for fractional logistic re…
Reshape ILO data Code: * Example generated by -dataex-. To install: ssc install dataex clear input str55 Country st…
Problem with DID interpretationDear all, I am trying to analyse the effect of higher tuition fees on grade outcomes. My data is un…
Out of sample prediction with the RMSE - panel dataDear all, I would like to run a panel regression for a subset of the time period of my dataset and …
likert scale analysisI have collected data from 300 respondents on their perception about water stress in their area. The…
Subscribe to:
Post Comments (Atom)
0 Response to Making foreach go through multiple variables but stops when one criteria is met
Post a Comment