Hi everyone, thanks so much for taking the time to help me.
Having some trouble using different variable lists in a for loop. I am using time series data measuring number of orders of mammograms on a given day. The celebrity variables (Phillips_60, etc.) label a 60 day window after a certain event. The goal is to generate two variables (popularity, awareness) that label the 60-day window with the corresponding popularity and awareness scores. I've cut a few variables and numbers out out for the sake of clarity.
The main error message I get is "if not found" and I've been stuck on this problem for a while, and I would truly appreciate any help.
Here' s the code I've got now.
gen popularity = 0
gen awareness = 0
foreach var of varlist Phillips_60 Lee_60 Urich_60 Harris_60 Mizell_60 {
local i = `i' + 1
*local celeb: word `i' of `varlist1'
local pop_values : word `i' of "2.095" "2.759" "2.726" "2.808" "1.879"
replace popularity = `pop_values' if `var' == 1
local aware_values : word `i' of "0.074" "0.470" "0.286" "0.343" "0.066"
replace awareness = `aware_values' if `var' == 1
}
Having some trouble using different variable lists in a for loop. I am using time series data measuring number of orders of mammograms on a given day. The celebrity variables (Phillips_60, etc.) label a 60 day window after a certain event. The goal is to generate two variables (popularity, awareness) that label the 60-day window with the corresponding popularity and awareness scores. I've cut a few variables and numbers out out for the sake of clarity.
The main error message I get is "if not found" and I've been stuck on this problem for a while, and I would truly appreciate any help.
Here' s the code I've got now.
gen popularity = 0
gen awareness = 0
foreach var of varlist Phillips_60 Lee_60 Urich_60 Harris_60 Mizell_60 {
local i = `i' + 1
*local celeb: word `i' of `varlist1'
local pop_values : word `i' of "2.095" "2.759" "2.726" "2.808" "1.879"
replace popularity = `pop_values' if `var' == 1
local aware_values : word `i' of "0.074" "0.470" "0.286" "0.343" "0.066"
replace awareness = `aware_values' if `var' == 1
}
Comment