I know basic stata coding but am primarily using R at this point, where I know how to do a lot more advanced work. I got a piece of stata code that I need to recreate in R, and I have no idea what is going on. It looks like this:
Code:
global n_medians : word count $medians
global i = 1
while $i <= $n_medians {
global median : word $i of $medians
global weight : word $i of $median_weights
gen weight_$median = $weight if ($median != .)
replace $median = $median * weight_$median
global missweights $missweights weight_$median
global i = $i + 1
}
Can someone please just explain what each of these steps are doing? I don't understand global macros in stata, I'm not sure what the $ does, and I'm completely lost on what word count is supposed to do. Any help would be appreciated.
0 Response to interpreting advanced stata code: global, word count
Post a Comment