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?
Creating Dummy VariableDear Statalist Experts I need to create a dummy variable from the following variable "A" with top a…
Type of correlation used by factorHi, I've done a factor analysis using the default settings for the factor command: factor item1-item…
Replication code for Stata 14 and Stata16 producing different resultsI ran into a problem where a data replicator could not replicate an item response variable using the…
Export dataset to LaTeXDear Stata Users, I have a dataset below. I want to export the data to the latex as the following t…
matching counties based on first two digits for finding similar stateHello, I have a data which shows distance between all counties from another county. This includes a…
Subscribe to:
Post Comments (Atom)
0 Response to How do I save scalars in a loop to a variable?
Post a Comment