Sorry this should be simple. I have a dataset that I want to collapse. It is proprietary so I can't post it.
Here are the commands I entered:
. fsum party - partyideology income attend - presapp mip* sat* proud democrat - atheistagnostic *imm* leveldissatisfactionimmigration fulllevel
> satisfactionimmig satimmigration newsat_immig newimmigration_2 newimmigration_2_fs impt_immig
Variable | N Mean SD Min Max
---------------------------------+---------------------------------------------
party | 226621 3.00 1.67 1.00 5.00
partyr | 226984 2.01 0.98 1.00 9.00
partyrr | 226984 2.00 0.83 1.00 9.00
pres_party | 229264 2.25 2.27 1.00 9.00
ideology | 221979 2.80 1.03 1.00 5.00
ideology5 | 226293 2.80 1.02 1.00 5.00
ideology3 | 226293 1.83 0.77 1.00 3.00
partyideology | 225934 3.72 1.96 1.00 6.00
income | 179007 6.40 3.01 1.00 13.00
attend | 224534 2.97 1.54 1.00 5.00
attend3 | 224534 2.17 0.86 1.00 3.00
religiousright | 0
bornagain | 0
presapp | 229264 0.59 0.72 0.00 4.00
mip1 | 229134 29.78 22.00 1.00 96.00
mip2 | 223677 81.76 29.14 1.00 96.00
mip3 | 51387 71.04 34.67 1.00 96.00
mipterrorism | 229264 0.12 0.32 0.00 1.00
mipecon | 229264 0.32 0.47 0.00 1.00
mipforeignpolicy | 229264 0.10 0.30 0.00 1.00
miphealthcare | 229264 0.07 0.25 0.00 1.00
mipgovt | 229264 0.17 0.38 0.00 1.00
mipmoral | 229264 0.06 0.23 0.00 1.00
mip_party | 34184 2.11 0.99 1.00 3.00
mipfp1 | 23081 9.09 4.96 1.00 23.00
mipfp2 | 18701 86.68 26.75 1.00 96.00
mipfp3 | 2031 73.19 38.07 1.00 96.00
mipwelfare | 228735 1.00 0.03 0.00 1.00
mipeconomics | 229264 0.00 0.00 0.00 0.00
satisfyus | 229264 1.69 0.52 1.00 4.00
satisfyusrecoded | 201653 2.92 1.00 1.00 4.00
satisfypersonal | 116863 0.91 0.43 0.00 4.00
satisfypersonalrecoded | 105235 1.58 0.82 1.00 4.00
sat_qual_life | 228069 1.95 0.79 1.00 4.00
sat_sys_govt | 224601 2.61 1.00 1.00 4.00
sat_pwr_govt | 223040 2.83 0.94 1.00 4.00
sat_moral_clmt | 223236 3.02 0.91 1.00 4.00
sat_opportunity | 224775 2.15 1.02 1.00 4.00
sat_corporations | 220554 2.89 0.93 1.00 4.00
sat_org_relig | 215822 2.43 0.96 1.00 4.00
sat_distr_wealth | 99412 2.98 1.01 1.00 4.00
sat_abortion | 200778 2.73 1.02 1.00 4.00
sat_crime | 216684 2.67 0.90 1.00 4.00
sat_economy | 220593 2.72 0.93 1.00 4.00
sat_education | 221525 2.83 0.96 1.00 4.00
sat_energy | 197015 2.77 0.92 1.00 4.00
sat_envt | 217505 2.54 0.91 1.00 4.00
sat_us_role_world | 216645 2.64 0.97 1.00 4.00
sat_gun_laws | 215491 2.72 1.06 1.00 4.00
sat_accept_gay | 210169 2.66 0.98 1.00 4.00
sat_avail_hc | 219813 3.00 0.99 1.00 4.00
sat_military | 215870 2.04 0.96 1.00 4.00
sat_poverty | 218965 3.08 0.88 1.00 4.00
sat_race_rel | 211613 2.69 0.90 1.00 4.00
sat_taxes | 219272 2.89 0.92 1.00 4.00
sat_ss_medicare | 214511 2.73 0.99 1.00 4.00
sat_qual_med | 197527 2.52 1.04 1.00 4.00
sat_terrorism | 205617 2.40 0.96 1.00 4.00
sat_govt_surv | 32436 2.92 0.97 1.00 4.00
sat_camp_fin | 114502 3.08 0.90 1.00 4.00
sat_pos_min | 162844 2.51 0.91 1.00 4.00
sat_pos_women | 149417 2.20 0.88 1.00 4.00
sat_gov_reg_biz | 68829 2.83 0.91 1.00 4.00
sat_corporations_rec | 185958 2.30 1.06 1.00 4.00
sat_org_relig_rec | 186704 1.82 1.07 1.00 4.00
sat_abortion_rec | 200778 1.94 1.04 1.00 4.00
sat_gun_laws_rec | 197103 1.77 0.89 1.00 4.00
sat_accept_gay_rec | 229264 5.00 0.00 5.00 5.00
sat_taxes_rec | 131203 2.34 1.12 1.00 4.00
sat_gov_reg_biz_rec | 65217 2.44 1.34 1.00 5.00
satisfiedstate | 61982 1.42 0.54 1.00 4.00
satisfiedlocalarea | 61982 1.23 0.45 1.00 4.00
satisfiednow | 98968 2.17 0.82 1.00 5.00
satisfiedfiveyearsago | 99034 2.40 0.98 1.00 5.00
satisfiedfiveyearshence | 97564 1.84 0.87 1.00 5.00
satisfiedhhincome | 7157 2.13 1.19 1.00 5.00
satisfiedjob | 3769 1.62 0.92 1.00 5.00
satisfiedstandardliving | 7204 1.99 1.16 1.00 5.00
satisfiededucation | 7194 1.58 0.90 1.00 5.00
satisfiedhealth | 7205 1.95 1.13 1.00 5.00
satisfiedfamilylife | 7197 1.53 0.97 1.00 5.00
satisfiedcommunity | 7216 1.70 1.03 1.00 5.00
satisfiedhousing | 7208 1.53 0.99 1.00 5.00
satisfiedleisuretime | 7191 1.90 1.21 1.00 5.00
sat_abortiondem | 62708 2.58 1.02 1.00 4.00
sat_crimedem | 66894 2.66 0.87 1.00 4.00
sat_org_relig_recdem | 58284 2.01 1.10 1.00 4.00
sat_abortion_recdem | 62708 1.96 1.12 1.00 4.00
sat_gun_laws_recdem | 61060 1.84 0.71 1.00 4.00
sat_accept_gay_recdem | 70707 5.00 0.00 5.00 5.00
satimmigration | 138326 0.10 0.30 0.00 1.00
sat_gov_reg_bizdem | 19837 2.80 0.88 1.00 4.00
sat_gov_reg_bizrep | 19837 2.80 0.88 1.00 4.00
sat_abortionrep | 91833 2.87 1.00 1.00 4.00
sat_crimerep | 98129 2.65 0.91 1.00 4.00
sat_org_relig_recrep | 84265 1.59 0.98 1.00 4.00
sat_abortion_recrep | 91833 1.91 0.94 1.00 4.00
sat_gun_laws_recrep | 89265 1.68 0.99 1.00 4.00
sat_accept_gay_recrep | 103081 5.00 0.00 5.00 5.00
proud | 50350 1.66 1.03 1.00 7.00
democrat | 226621 0.31 0.46 0.00 1.00
republican | 226621 0.45 0.50 0.00 1.00
independent | 226621 0.09 0.28 0.00 1.00
liberal | 226293 0.23 0.42 0.00 1.00
moderate | 226293 0.38 0.48 0.00 1.00
conservative | 226293 0.40 0.49 0.00 1.00
protestant | 211577 0.52 0.50 0.00 1.00
catholic | 211577 0.23 0.42 0.00 1.00
mormon | 211577 0.02 0.12 0.00 1.00
otherchristian | 211577 0.01 0.10 0.00 1.00
jewish | 211577 0.03 0.16 0.00 1.00
nonchristian | 211577 0.01 0.12 0.00 1.00
otherrelig | 211577 0.02 0.14 0.00 1.00
atheistagnostic | 211577 0.13 0.34 0.00 1.00
overallsatisfactionimmigration | 229264 0.59 0.91 0.00 2.00
leveldissatisfactionimmigration | 138326 0.10 0.30 0.00 1.00
fulllevelsatisfactionimmig | 97953 0.08 0.27 0.00 1.00
finallevelsatisfactionimmig | 229264 0.72 0.96 0.00 2.00
impt_immig | 229264 0.05 0.22 0.00 1.00
impt_immigdum | 20995 0.88 0.32 0.00 1.00
newsat_immig | 128092 2.37 0.63 1.00 3.00
newimmigration_2 | 138326 2.57 0.67 1.00 3.00
newimmigration_2_fs | 97953 2.47 0.64 1.00 3.00
overallimmig | 229264 0.59 0.91 0.00 2.00
overallimmigdem | 63924 2.79 0.92 1.00 4.00
satimmigration | 138326 0.10 0.30 0.00 1.00
overallimmigrep | 229264 0.19 0.58 0.00 2.00
newsat_immignew | 128092 0.55 0.50 0.00 1.00
newimmigration_2new | 138326 0.33 0.47 0.00 1.00
newimmigration_2_fsnew | 97953 0.45 0.50 0.00 1.00
leveldissatisfactionimmigration | 138326 0.10 0.30 0.00 1.00
fulllevelsatisfactionimmig | 97953 0.08 0.27 0.00 1.00
satimmigration | 138326 0.10 0.30 0.00 1.00
newsat_immig | 128092 2.37 0.63 1.00 3.00
newimmigration_2 | 138326 2.57 0.67 1.00 3.00
newimmigration_2_fs | 97953 2.47 0.64 1.00 3.00
impt_immig | 229264 0.05 0.22 0.00 1.00
.
I entered the collapse command with the following Stata response:
collapse party - partyideology income attend - presapp mip* sat* proud democrat - atheistagnostic *imm* leveldissatisfactionimmigration fulll
> evelsatisfactionimmig satimmigration newsat_immig newimmigration_2 newimmigration_2_fs impt_immig ,by(state)
error:
satimmigration = (mean) satimmigration
satimmigration = (mean) satimmigration
name conflict
r(198);
Why does this occur when:
. tab satimmigration
satimmigrat |
ion | Freq. Percent Cum.
------------+-----------------------------------
0 | 124,078 89.70 89.70
1 | 14,248 10.30 100.00
------------+-----------------------------------
Total | 138,326 100.00
Any help would be appreciated.
Ric Uslaner
Here are the commands I entered:
. fsum party - partyideology income attend - presapp mip* sat* proud democrat - atheistagnostic *imm* leveldissatisfactionimmigration fulllevel
> satisfactionimmig satimmigration newsat_immig newimmigration_2 newimmigration_2_fs impt_immig
Variable | N Mean SD Min Max
---------------------------------+---------------------------------------------
party | 226621 3.00 1.67 1.00 5.00
partyr | 226984 2.01 0.98 1.00 9.00
partyrr | 226984 2.00 0.83 1.00 9.00
pres_party | 229264 2.25 2.27 1.00 9.00
ideology | 221979 2.80 1.03 1.00 5.00
ideology5 | 226293 2.80 1.02 1.00 5.00
ideology3 | 226293 1.83 0.77 1.00 3.00
partyideology | 225934 3.72 1.96 1.00 6.00
income | 179007 6.40 3.01 1.00 13.00
attend | 224534 2.97 1.54 1.00 5.00
attend3 | 224534 2.17 0.86 1.00 3.00
religiousright | 0
bornagain | 0
presapp | 229264 0.59 0.72 0.00 4.00
mip1 | 229134 29.78 22.00 1.00 96.00
mip2 | 223677 81.76 29.14 1.00 96.00
mip3 | 51387 71.04 34.67 1.00 96.00
mipterrorism | 229264 0.12 0.32 0.00 1.00
mipecon | 229264 0.32 0.47 0.00 1.00
mipforeignpolicy | 229264 0.10 0.30 0.00 1.00
miphealthcare | 229264 0.07 0.25 0.00 1.00
mipgovt | 229264 0.17 0.38 0.00 1.00
mipmoral | 229264 0.06 0.23 0.00 1.00
mip_party | 34184 2.11 0.99 1.00 3.00
mipfp1 | 23081 9.09 4.96 1.00 23.00
mipfp2 | 18701 86.68 26.75 1.00 96.00
mipfp3 | 2031 73.19 38.07 1.00 96.00
mipwelfare | 228735 1.00 0.03 0.00 1.00
mipeconomics | 229264 0.00 0.00 0.00 0.00
satisfyus | 229264 1.69 0.52 1.00 4.00
satisfyusrecoded | 201653 2.92 1.00 1.00 4.00
satisfypersonal | 116863 0.91 0.43 0.00 4.00
satisfypersonalrecoded | 105235 1.58 0.82 1.00 4.00
sat_qual_life | 228069 1.95 0.79 1.00 4.00
sat_sys_govt | 224601 2.61 1.00 1.00 4.00
sat_pwr_govt | 223040 2.83 0.94 1.00 4.00
sat_moral_clmt | 223236 3.02 0.91 1.00 4.00
sat_opportunity | 224775 2.15 1.02 1.00 4.00
sat_corporations | 220554 2.89 0.93 1.00 4.00
sat_org_relig | 215822 2.43 0.96 1.00 4.00
sat_distr_wealth | 99412 2.98 1.01 1.00 4.00
sat_abortion | 200778 2.73 1.02 1.00 4.00
sat_crime | 216684 2.67 0.90 1.00 4.00
sat_economy | 220593 2.72 0.93 1.00 4.00
sat_education | 221525 2.83 0.96 1.00 4.00
sat_energy | 197015 2.77 0.92 1.00 4.00
sat_envt | 217505 2.54 0.91 1.00 4.00
sat_us_role_world | 216645 2.64 0.97 1.00 4.00
sat_gun_laws | 215491 2.72 1.06 1.00 4.00
sat_accept_gay | 210169 2.66 0.98 1.00 4.00
sat_avail_hc | 219813 3.00 0.99 1.00 4.00
sat_military | 215870 2.04 0.96 1.00 4.00
sat_poverty | 218965 3.08 0.88 1.00 4.00
sat_race_rel | 211613 2.69 0.90 1.00 4.00
sat_taxes | 219272 2.89 0.92 1.00 4.00
sat_ss_medicare | 214511 2.73 0.99 1.00 4.00
sat_qual_med | 197527 2.52 1.04 1.00 4.00
sat_terrorism | 205617 2.40 0.96 1.00 4.00
sat_govt_surv | 32436 2.92 0.97 1.00 4.00
sat_camp_fin | 114502 3.08 0.90 1.00 4.00
sat_pos_min | 162844 2.51 0.91 1.00 4.00
sat_pos_women | 149417 2.20 0.88 1.00 4.00
sat_gov_reg_biz | 68829 2.83 0.91 1.00 4.00
sat_corporations_rec | 185958 2.30 1.06 1.00 4.00
sat_org_relig_rec | 186704 1.82 1.07 1.00 4.00
sat_abortion_rec | 200778 1.94 1.04 1.00 4.00
sat_gun_laws_rec | 197103 1.77 0.89 1.00 4.00
sat_accept_gay_rec | 229264 5.00 0.00 5.00 5.00
sat_taxes_rec | 131203 2.34 1.12 1.00 4.00
sat_gov_reg_biz_rec | 65217 2.44 1.34 1.00 5.00
satisfiedstate | 61982 1.42 0.54 1.00 4.00
satisfiedlocalarea | 61982 1.23 0.45 1.00 4.00
satisfiednow | 98968 2.17 0.82 1.00 5.00
satisfiedfiveyearsago | 99034 2.40 0.98 1.00 5.00
satisfiedfiveyearshence | 97564 1.84 0.87 1.00 5.00
satisfiedhhincome | 7157 2.13 1.19 1.00 5.00
satisfiedjob | 3769 1.62 0.92 1.00 5.00
satisfiedstandardliving | 7204 1.99 1.16 1.00 5.00
satisfiededucation | 7194 1.58 0.90 1.00 5.00
satisfiedhealth | 7205 1.95 1.13 1.00 5.00
satisfiedfamilylife | 7197 1.53 0.97 1.00 5.00
satisfiedcommunity | 7216 1.70 1.03 1.00 5.00
satisfiedhousing | 7208 1.53 0.99 1.00 5.00
satisfiedleisuretime | 7191 1.90 1.21 1.00 5.00
sat_abortiondem | 62708 2.58 1.02 1.00 4.00
sat_crimedem | 66894 2.66 0.87 1.00 4.00
sat_org_relig_recdem | 58284 2.01 1.10 1.00 4.00
sat_abortion_recdem | 62708 1.96 1.12 1.00 4.00
sat_gun_laws_recdem | 61060 1.84 0.71 1.00 4.00
sat_accept_gay_recdem | 70707 5.00 0.00 5.00 5.00
satimmigration | 138326 0.10 0.30 0.00 1.00
sat_gov_reg_bizdem | 19837 2.80 0.88 1.00 4.00
sat_gov_reg_bizrep | 19837 2.80 0.88 1.00 4.00
sat_abortionrep | 91833 2.87 1.00 1.00 4.00
sat_crimerep | 98129 2.65 0.91 1.00 4.00
sat_org_relig_recrep | 84265 1.59 0.98 1.00 4.00
sat_abortion_recrep | 91833 1.91 0.94 1.00 4.00
sat_gun_laws_recrep | 89265 1.68 0.99 1.00 4.00
sat_accept_gay_recrep | 103081 5.00 0.00 5.00 5.00
proud | 50350 1.66 1.03 1.00 7.00
democrat | 226621 0.31 0.46 0.00 1.00
republican | 226621 0.45 0.50 0.00 1.00
independent | 226621 0.09 0.28 0.00 1.00
liberal | 226293 0.23 0.42 0.00 1.00
moderate | 226293 0.38 0.48 0.00 1.00
conservative | 226293 0.40 0.49 0.00 1.00
protestant | 211577 0.52 0.50 0.00 1.00
catholic | 211577 0.23 0.42 0.00 1.00
mormon | 211577 0.02 0.12 0.00 1.00
otherchristian | 211577 0.01 0.10 0.00 1.00
jewish | 211577 0.03 0.16 0.00 1.00
nonchristian | 211577 0.01 0.12 0.00 1.00
otherrelig | 211577 0.02 0.14 0.00 1.00
atheistagnostic | 211577 0.13 0.34 0.00 1.00
overallsatisfactionimmigration | 229264 0.59 0.91 0.00 2.00
leveldissatisfactionimmigration | 138326 0.10 0.30 0.00 1.00
fulllevelsatisfactionimmig | 97953 0.08 0.27 0.00 1.00
finallevelsatisfactionimmig | 229264 0.72 0.96 0.00 2.00
impt_immig | 229264 0.05 0.22 0.00 1.00
impt_immigdum | 20995 0.88 0.32 0.00 1.00
newsat_immig | 128092 2.37 0.63 1.00 3.00
newimmigration_2 | 138326 2.57 0.67 1.00 3.00
newimmigration_2_fs | 97953 2.47 0.64 1.00 3.00
overallimmig | 229264 0.59 0.91 0.00 2.00
overallimmigdem | 63924 2.79 0.92 1.00 4.00
satimmigration | 138326 0.10 0.30 0.00 1.00
overallimmigrep | 229264 0.19 0.58 0.00 2.00
newsat_immignew | 128092 0.55 0.50 0.00 1.00
newimmigration_2new | 138326 0.33 0.47 0.00 1.00
newimmigration_2_fsnew | 97953 0.45 0.50 0.00 1.00
leveldissatisfactionimmigration | 138326 0.10 0.30 0.00 1.00
fulllevelsatisfactionimmig | 97953 0.08 0.27 0.00 1.00
satimmigration | 138326 0.10 0.30 0.00 1.00
newsat_immig | 128092 2.37 0.63 1.00 3.00
newimmigration_2 | 138326 2.57 0.67 1.00 3.00
newimmigration_2_fs | 97953 2.47 0.64 1.00 3.00
impt_immig | 229264 0.05 0.22 0.00 1.00
.
I entered the collapse command with the following Stata response:
collapse party - partyideology income attend - presapp mip* sat* proud democrat - atheistagnostic *imm* leveldissatisfactionimmigration fulll
> evelsatisfactionimmig satimmigration newsat_immig newimmigration_2 newimmigration_2_fs impt_immig ,by(state)
error:
satimmigration = (mean) satimmigration
satimmigration = (mean) satimmigration
name conflict
r(198);
Why does this occur when:
. tab satimmigration
satimmigrat |
ion | Freq. Percent Cum.
------------+-----------------------------------
0 | 124,078 89.70 89.70
1 | 14,248 10.30 100.00
------------+-----------------------------------
Total | 138,326 100.00
Any help would be appreciated.
Ric Uslaner
Comment