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
Panel Data - Random effect model vs Pooled OLSHi Statalist This is my first post, so bear with me if I make some mistakes. I am conducting a Pan…
Base category not displayedFellow stata users, I am having trouble getting state to display the base category of the interactio…
convergence not achieved in GMM ModelDear Statailist I run the GMM regression of my variables in STATA and I have error that w that "co…
ARIMA ModelI am trying to find the arima model that has uncorrelated residuals. I plotted the AC and PAC. I obs…
reshaping OECD panel data with not unique within i(var1 var2) problemHi, Stata masters. I have a problem with reshaping the common panel data which shows " with not uniq…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a loop to count the weeks before and after a policy
Post a Comment