X hits on this document

Word document

click on “Load Preferences”; (4) click on “Factory Settings.” If the ... - page 30 / 44

400 views

0 shares

0 downloads

0 comments

30 / 44

STATA “DO” Files

The “do file” below was for an annual data set (1976-2003) stacked by state (i.e., observation #1 was Alabama for 1976, observation #2 was Alabama for 1977, etc.) where I wanted the average score on id1 for the

1980-89 period – the average score on id3 for the same period for all states.  Also, the same procedure for the 1980-89 period.

use "C:\EriksonWrightMcIverUpdate.dta", clear

keep stateid year id1 id3

sort state year

list in 1/10

foreach val in 1 3 {

egen eighties_id`val' = total(id`val') ///

if year > 1979 & year < 1990, by(state)

egen nineties_id`val' = total(id`val') ///

if year > 1989 & year < 2000, by(state)

sort stateid eighties_id`val'

by stateid : replace eighties_id`val' = ///

eighties_id`val'[_n-1] if eighties_id`val' == .

sort stateid nineties_id`val'

by stateid : replace nineties_id`val' = ///

nineties_id`val'[_n-1] if nineties_id`val' == .

replace eighties_id`val' = eighties_id`val'/10

replace nineties_id`val' = nineties_id`val'/10

}

gen ideology8089 = eighties_id1 - eighties_id3

gen ideology9099 = nineties_id1 - nineties_id3

drop eight* nine*

The following commands were used to find the number of years between 1989 and 2002 that the Democrats were in “control” (i.e., had a majority of both houses of the state legislature and the governorship) in each state.  Stnum was simply the state number (i.e., Alabama was state #1)

use "C:\StatePoliticalData19492006.dta", clear

gen flag = uhdem>uhrep & lhdem>lhrep & demgov ==1 & year>1988 &      

                  year<2003

egen demcontrol=total(flag), by(stnum)

tabulate stnum, summ (demcontrol)

The following commands were used to obtain the average Democratic

strength in each state’s government over the 1989-2002 period (lower house worth 25%, upper house worth 25% and the governorship worth 50% -

i.e., the maximum value would be 1.0)

use "C:\StatePoliticalData19492006.dta", clear

gen dem_strength = .

levelsof stnum

  foreach st in `r(levels)' {

           local total_percent=0 //

           foreach val in lh uh {

Document info
Document views400
Page views463
Page last viewedSat Dec 03 16:39:19 UTC 2016
Pages44
Paragraphs843
Words17107

Comments