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
Drop observations if not meeting frequency criteriumMy dataset consists of time-series observation of US firms with identifiers like gvkey, cusip and a …
sample size-new From a published study we have the following information. Here there is only one group (preterm inf…
Creating a 2 Y-axis line using two datasetsHello Stata community; I have 2 Stata datasets: one is called Republicans, and the other one is Suns…
Reference group with multiple dichotomous variablesHello Statalist I have a question regarding how to interpret the reference group in my logistic reg…
New package -rori- on the SSCThanks to Kit Baum, there is a new package -rori- on the SSC. rori -- Immediate command for estimat…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a loop to count the weeks before and after a policy
Post a Comment