Hi,
I'm working on understanding the impact of a hospital policy on healthcare utilization. The policy was implemented in March of 2020. I need to create variable that increases by 1 for every week after the policy and decreases by 1 for every week before the policy. I know I could do it by creating a lot of replace statements e.g.
gen policy_week=0 if week==11 & year==2020
replace policy_week=1 if week==12 & year==2020
replace policy_week=2 if week==13 & year==2020
replace policy_week=3 if week==14 & year==2020
replace policy_week=4 if week==15 & year==2020
.
.
.
replace policy_week=-1 if week==10 & year==2020
replace policy_week=-2 if week==9 & year==2020
replace policy_week=-3if week==8 & year==2020
replace policy_week=-4 if week==7 & year==2020
But I would like to try it doing a loop. Any guidance on how to best do this?
Related Posts with Creating a loop to count the weeks before and after a policy
Truncating numerical dates to yearsI am trying to merge a few datasets, and one of them uses very specific date information in a format…
Help selecting font with collect style putdocxHi, I am trying to export a collection to an MS Word document where the entire table uses the "Time…
COEFPLOT, MLABEL(): Line break appears on PNG but not PDFHello all, I am using COEFPLOT and trying to add a line break to the marker label. Specifically, at …
Large panel model: counting time periods since variable ==1Hi I have a very large panel dataset (50 time periods, 30m panel IDs) and I have a variable (called…
Problem with localsMinor but annoying problem with locals. I have a long variable list that I would like to add to a fi…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a loop to count the weeks before and after a policy
Post a Comment