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?
-order(c.(A C B)#c.X) option does not work with esttab?Dear all, I use the following commands to make a table: eststo: reg Y c.(A B C)#c.X esttab, order(…
how to systemmatically change data entry 200thousand alike into 200000many thanks! …
How to loop over columns of 70 to get the categorical counts based on a particular observation?Hi all, I've a hospital cases dataset having 30 columns and 70 observations. Based on the types of …
How to import tabstat results to data editor?Hello, I want to know to import the tabstat results to a stata data editor. I am using the followin…
grmap without shapefileDear Statalist members, Under the framework of spatial analysis, I have a dataset with coordinates …
Subscribe to:
Post Comments (Atom)
0 Response to How do I save scalars in a loop to a variable?
Post a Comment