Hello everyone!
I'd like to save two scalars generated in a loop to a variable. My current code reads as follows:
-------------------------
forvalues i = 1(1)158 {
gen z = _b[_cons] + _b[republican]*republican + _b[ideology]*ideology + _b[vulnerability]*vulnerability + _b[seniority]*seniority if vote_id == 'i'
gen Phi_z = normal(z)
gen newvote = 1 if vote_id == 'i'
replace newvote = 0 if Phi_z < .5 if vote_id == 'i'
sum vote_behavior if vote_id == 'i'
scalar vote_old = r(mean)
sum newvote
scalar vote_new = r(mean)
}
-------------------------
I'd like to save the scalars vote_old and vote_new to new variables. I'd appreciate any suggestions on how to do that.
G.
Related Posts with How do I save scalars in a loop to a variable?
generating a count using stratified dataI am working with a stratified dataset involving clinic data, specifically, patient characteristics …
multiple regression when significant difference between groups within 1 regression?Hi there, I am studying the effect of becoming a parent on the earnings of fathers versus mothers. …
How to draw Chinese map in stata?Dear statalisits, I recently puzzeled by using stata to draw Chinese map. "How to draw Chinese map i…
Putexcel, Save Multiple Tables into One ExcelHello everyone, I am a beginner in Stata and encountered a problem while using putexcel. I ran: bys…
twoway scatter plot with bar overlay — opacity issuesHi everyone, I'm trying to create a bar plot using the twoway command with scatterplots "behind" th…
Subscribe to:
Post Comments (Atom)
0 Response to How do I save scalars in a loop to a variable?
Post a Comment