#delimit ;
factor 
 confinan 
 conbus   
 conclerg 
 coneduc  
 confed   
 conlabor 
 conpress 
 conmedic 
 contv    
 conjudge 
 consci   
 conlegis 
 conarmy,
  ipf;
screeplot, mean;
rotate, promax(3) oblique blank(.3) factors(5);
#delimit cr


local check "confinan conbus conclerg coneduc confed conlabor conpress conmedic contv conjudge consci conlegis conarmy"
foreach var of varlist `check' {
  tab `var'
}
tabstat `check', by(year)

local check "confed conjudge conlegis confinan conbus conarmy conclerg coneduc conmedic"
foreach var of varlist `check' {
  vreverse `var', gen(`var'1)
}

/* Generate Confidence Scales */

#delimit ;
gen confidence=confed1   + conjudge1 + conlegis1-3 +
               confinan1 + conbus1   + conarmy1 -3 +
               conclerg1 + coneduc1  + conmedic1-3;
#delimit cr
gen congov     =confed1   + conjudge1 + conlegis1-3
gen conmilindus=confinan1 + conbus1   + conarmy1 -3
gen conspirit  =conclerg1 + coneduc1  + conmedic1-3
label variable confidence  "Americna Confidence in Institutions Scale"
label variable congov      "Confidence in the Government"
label variable conmilindus "Confidence in the Military-Indistrial Complex"
label variable conspirit   "Confidence in Spirtual, Educational, and Medical Institutions"
#delimit ;
alpha confed1   conjudge1 conlegis1
      confinan1 conbus1   conarmy1
      conclerg1 coneduc1  conmedic1, item;
#delimit cr
alpha confed1   conjudge1 conlegis1, item
alpha confinan1 conbus1   conarmy1,  item
alpha conclerg1 coneduc1  conmedic1, item
drop confed1-conmedic1

#delimit ;
hist confidence, normal percent discrete 
   title("Confidence in American Institutions Scale")
   xlabel(0(1)18)
   ymtick(0(1)15)
   name(confidence, replace)
;

hist congov, normal percent discrete 
   title("Confidence in Government Institutions Scale")
   xlabel(0(1)6)
   ymtick(0(5)30)
   name(congov, replace)
;
hist conmilindus, normal percent discrete 
   title("Confidence in The Military-Industrial Complex Scale")
   xlabel(0(1)6)
   ymtick(0(5)30)
   name(conmilindus, replace)
;
hist conspirit, normal percent discrete 
   title("Confidence in Clergy, Education, and Medicine Scale")
   xlabel(0(1)6)
   ymtick(0(5)40)
   name(conspirit, replace) 
;
#delimit cr

recode partyid (0/2=0 "Democrat") (3=.) (4/7=1 "Republican"), gen(party)

ttest confidence  if year==2004, by(party)
ttest congov      if year==2004, by(party)
ttest conmilindus if year==2004, by(party)
ttest conspirit   if year==2004, by(party)

ttest confidence  if race<3 & year==2004, by(race)
ttest congov      if race<3 & year==2004, by(race)
ttest conmilindus if race<3 & year==2004, by(race)
ttest conspirit   if race<3 & year==2004, by(race)