dropping data
II want to drop variables from a datset where there are ommissing values. I typed
. fre immfactor country if immfactor ~= .
immfactor -- takejobs crime strainwelfare owncustoms
---------------------------------------------------------------
| Freq. Percent Valid Cum.
------------------+--------------------------------------------
Valid -1.385437 | 3286 2.97 2.97 2.97
-1.375464 | 322 0.29 0.29 3.26
-1.36549 | 346 0.31 0.31 3.57
-1.355517 | 214 0.19 0.19 3.76
-1.345544 | 219 0.20 0.20 3.96
-1.335571 | 624 0.56 0.56 4.52
-1.325597 | 123 0.11 0.11 4.64
-1.315624 | 182 0.16 0.16 4.80
-1.313048 | 282 0.25 0.25 5.05
-1.305651 | 159 0.14 0.14 5.20
-1.303075 | 94 0.08 0.08 5.28
-1.295678 | 2527 2.28 2.28 7.56
-1.293101 | 97 0.09 0.09 7.65
-1.283128 | 46 0.04 0.04 7.69
-1.273155 | 35 0.03 0.03 7.72
-1.263182 | 86 0.08 0.08 7.80
-1.253208 | 35 0.03 0.03 7.83
-1.243261 | 104 0.09 0.09 7.93
-1.243235 | 48 0.04 0.04 7.97
-1.242571 | 80 0.07 0.07 8.04
: | : : : :
1.77834 | 43 0.04 0.04 96.08
1.779005 | 12 0.01 0.01 96.09
1.779031 | 45 0.04 0.04 96.13
1.788978 | 9 0.01 0.01 96.14
1.798951 | 12 0.01 0.01 96.15
1.808925 | 27 0.02 0.02 96.17
1.818898 | 6 0.01 0.01 96.18
1.828871 | 13 0.01 0.01 96.19
1.831447 | 1128 1.02 1.02 97.21
1.838844 | 14 0.01 0.01 97.22
1.841421 | 68 0.06 0.06 97.28
1.848818 | 43 0.04 0.04 97.32
1.851394 | 110 0.10 0.10 97.42
1.861367 | 128 0.12 0.12 97.54
1.87134 | 184 0.17 0.17 97.70
1.881314 | 623 0.56 0.56 98.27
1.891287 | 110 0.10 0.10 98.37
1.90126 | 144 0.13 0.13 98.50
1.911233 | 137 0.12 0.12 98.62
1.921207 | 1529 1.38 1.38 100.00
Total | 110759 100.00 100.00
---------------------------------------------------------------
country -- Country (ISO 3166-1 Numeric code)
--------------------------------------------------------------------------------
| Freq. Percent Valid Cum.
-----------------------------------+--------------------------------------------
Valid 8 Albania | 2486 2.24 2.24 2.24
31 Azerbaijan | 1448 1.31 1.31 3.55
40 Austria | 3008 2.72 2.72 6.27
51 Armenia | 2706 2.44 2.44 8.71
56 Belgium | 1488 1.34 1.34 10.05
70 Bosnia and Herzegovina | 2828 2.55 2.55 12.61
100 Bulgaria | 2218 2.00 2.00 14.61
112 Belarus | 2654 2.40 2.40 17.01
191 Croatia | 2681 2.42 2.42 19.43
196 Cyprus | 865 0.78 0.78 20.21
197 Northern Cyprus | 452 0.41 0.41 20.62
203 Czech Republic | 3242 2.93 2.93 23.54
208 Denmark | 4764 4.30 4.30 27.84
233 Estonia | 2451 2.21 2.21 30.06
246 Finland | 2166 1.96 1.96 32.01
250 France | 3138 2.83 2.83 34.85
268 Georgia | 2858 2.58 2.58 37.43
276 Germany | 4024 3.63 3.63 41.06
300 Greece | 1435 1.30 1.30 42.36
348 Hungary | 2785 2.51 2.51 44.87
: | : : : :
498 Moldova | 1211 1.09 1.09 58.48
499 Montenegro | 2184 1.97 1.97 60.45
528 Netherlands | 3668 3.31 3.31 63.76
578 Norway | 2169 1.96 1.96 65.72
616 Poland | 2453 2.21 2.21 67.93
620 Portugal | 2354 2.13 2.13 70.06
642 Romania | 2524 2.28 2.28 72.34
643 Russia | 2679 2.42 2.42 74.76
688 Serbia | 2559 2.31 2.31 77.07
703 Slovakia | 2565 2.32 2.32 79.38
705 Slovenia | 2235 2.02 2.02 81.40
724 Spain | 2455 2.22 2.22 83.62
752 Sweden | 2103 1.90 1.90 85.52
756 Switzerland | 4275 3.86 3.86 89.38
792 Turkey | 2069 1.87 1.87 91.24
804 Ukraine | 2420 2.18 2.18 93.43
807 North Macedonia | 2211 2.00 2.00 95.43
826 Great Britain | 3185 2.88 2.88 98.30
909 Northern Ireland | 435 0.39 0.39 98.69
915 Kosovo | 1447 1.31 1.31 100.00
Total | 110759 100.00 100.00
--------------------------------------------------------------------------------
.
. oneway immfactor country if immfactor ~= .,tab
Country |
(ISO 3166-1 | Summary of takejobs crime
Numeric | strainwelfare owncustoms
code) | Mean Std. Dev. Freq.
------------+------------------------------------
Albania | .52663247 .91669659 2,486
Azerbaij | .41242884 .75825759 1,448
Austria | -.34499898 .82297632 3,008
Armenia | .47523728 .74669216 2,706
Belgium | -.1342983 .75448219 1,488
Bosnia a | .04688463 .87830355 2,828
Bulgaria | -.23307162 .8599487 2,218
Belarus | -.02267476 .80367539 2,654
Croatia | .0175983 .85663715 2,681
Cyprus | -.56812984 .67338488 865
Northern | .23387116 1.0856686 452
Czech Re | -.41091566 .76977594 3,242
Denmark | -.04507802 .7441623 4,764
Estonia | -.08617654 .81005037 2,451
Finland | .06322009 .80574298 2,166
France | .26902951 .86031816 3,138
Georgia | .31850699 .93294149 2,858
Germany | -.16651872 .80024392 4,024
Greece | -.22786174 .81861355 1,435
Hungary | -.45008144 .79610421 2,785
Iceland | .47686534 .82023629 2,289
Ireland | -.2192179 .77487173 883
Italy | -.10612937 .83259777 3,303
Latvia | -.09514977 .74734859 2,348
Lithuani | -.16750899 .7170314 2,245
Luxembou | .26496319 .83185921 1,485
Malta | -.64797945 .60866197 1,308
Moldova | .12054501 .8428975 1,211
Monteneg | .22367822 .93590782 2,184
Netherla | .01379921 .75027059 3,668
Norway | -.03188767 .68567194 2,169
Poland | .12792221 .82211202 2,453
Portugal | .12159486 .7656805 2,354
Romania | .22670131 .96556158 2,524
Russia | -.24134028 .80454117 2,679
Serbia | -.06846114 .8731876 2,559
Slovakia | -.30673834 .7192112 2,565
Slovenia | -.01288831 .8123877 2,235
Spain | .26190901 .83062315 2,455
Sweden | .25258097 .87624981 2,103
Switzerl | .00209355 .77800164 4,275
Turkey | -.14600297 .84818332 2,069
Ukraine | .09837232 .85107846 2,420
North Ma | .18620844 1.0048139 2,211
Great Br | .04780672 .90185018 3,185
Northern | -.28429996 .76353595 435
Kosovo | -.17869994 .82166866 1,447
------------+------------------------------------
Total | -8.004e-10 .85779265 110,759
Analysis of Variance
Source SS df MS F Prob > F
------------------------------------------------------------------------
Between groups 6833.32589 46 148.550563 220.27 0.0000
Within groups 74663.3221 110712 .674392316
------------------------------------------------------------------------
Total 81496.648 110758 .735808231
Bartlett's test for equal variances: chi2(46) = 1.8e+03 Prob>chi2 = 0.000
. gen x = 1 if immfactor ~= .
(113,675 missing values generated)
.
.
. drop * i x
i ambiguous abbreviation
r(111);
.
.
.
.
.
.
.
.
. drop * if x
invalid syntax
r(198);
. drop * if x
invalid syntax
r(198);
.
.
.
.
.
.
. drop * if x ~= 1
invalid syntax
r(198);
. fre x
x
-------------------------------------------------------
| Freq. Percent Valid Cum.
----------+--------------------------------------------
Valid 1 | 110759 49.35 100.00 100.00
Missing . | 113675 50.65
Total | 224434 100.00
-------------------------------------------------------
. replace x = 0 if x ~= 1
(113,675 real changes made)
. fre x
x
-----------------------------------------------------------
| Freq. Percent Valid Cum.
--------------+--------------------------------------------
Valid 0 | 113675 50.65 50.65 50.65
1 | 110759 49.35 49.35 100.00
Total | 224434 100.00 100.00
-----------------------------------------------------------
. drop * if x == 0
invalid syntax
r(198);
. drop immfator if x == 0
variable immfator not found
r(111);
. drop immfactor if x == 0
invalid syntax
r(198);
. drop immfactor if x ~= 1
invalid syntax
r(198);
This seems to follow the manualbut I cannot delete the observations. What did I do wrong? Any help would be appreciated, Thanks,
Ric Uslaner
.
II want to drop variables from a datset where there are ommissing values. I typed
. fre immfactor country if immfactor ~= .
immfactor -- takejobs crime strainwelfare owncustoms
---------------------------------------------------------------
| Freq. Percent Valid Cum.
------------------+--------------------------------------------
Valid -1.385437 | 3286 2.97 2.97 2.97
-1.375464 | 322 0.29 0.29 3.26
-1.36549 | 346 0.31 0.31 3.57
-1.355517 | 214 0.19 0.19 3.76
-1.345544 | 219 0.20 0.20 3.96
-1.335571 | 624 0.56 0.56 4.52
-1.325597 | 123 0.11 0.11 4.64
-1.315624 | 182 0.16 0.16 4.80
-1.313048 | 282 0.25 0.25 5.05
-1.305651 | 159 0.14 0.14 5.20
-1.303075 | 94 0.08 0.08 5.28
-1.295678 | 2527 2.28 2.28 7.56
-1.293101 | 97 0.09 0.09 7.65
-1.283128 | 46 0.04 0.04 7.69
-1.273155 | 35 0.03 0.03 7.72
-1.263182 | 86 0.08 0.08 7.80
-1.253208 | 35 0.03 0.03 7.83
-1.243261 | 104 0.09 0.09 7.93
-1.243235 | 48 0.04 0.04 7.97
-1.242571 | 80 0.07 0.07 8.04
: | : : : :
1.77834 | 43 0.04 0.04 96.08
1.779005 | 12 0.01 0.01 96.09
1.779031 | 45 0.04 0.04 96.13
1.788978 | 9 0.01 0.01 96.14
1.798951 | 12 0.01 0.01 96.15
1.808925 | 27 0.02 0.02 96.17
1.818898 | 6 0.01 0.01 96.18
1.828871 | 13 0.01 0.01 96.19
1.831447 | 1128 1.02 1.02 97.21
1.838844 | 14 0.01 0.01 97.22
1.841421 | 68 0.06 0.06 97.28
1.848818 | 43 0.04 0.04 97.32
1.851394 | 110 0.10 0.10 97.42
1.861367 | 128 0.12 0.12 97.54
1.87134 | 184 0.17 0.17 97.70
1.881314 | 623 0.56 0.56 98.27
1.891287 | 110 0.10 0.10 98.37
1.90126 | 144 0.13 0.13 98.50
1.911233 | 137 0.12 0.12 98.62
1.921207 | 1529 1.38 1.38 100.00
Total | 110759 100.00 100.00
---------------------------------------------------------------
country -- Country (ISO 3166-1 Numeric code)
--------------------------------------------------------------------------------
| Freq. Percent Valid Cum.
-----------------------------------+--------------------------------------------
Valid 8 Albania | 2486 2.24 2.24 2.24
31 Azerbaijan | 1448 1.31 1.31 3.55
40 Austria | 3008 2.72 2.72 6.27
51 Armenia | 2706 2.44 2.44 8.71
56 Belgium | 1488 1.34 1.34 10.05
70 Bosnia and Herzegovina | 2828 2.55 2.55 12.61
100 Bulgaria | 2218 2.00 2.00 14.61
112 Belarus | 2654 2.40 2.40 17.01
191 Croatia | 2681 2.42 2.42 19.43
196 Cyprus | 865 0.78 0.78 20.21
197 Northern Cyprus | 452 0.41 0.41 20.62
203 Czech Republic | 3242 2.93 2.93 23.54
208 Denmark | 4764 4.30 4.30 27.84
233 Estonia | 2451 2.21 2.21 30.06
246 Finland | 2166 1.96 1.96 32.01
250 France | 3138 2.83 2.83 34.85
268 Georgia | 2858 2.58 2.58 37.43
276 Germany | 4024 3.63 3.63 41.06
300 Greece | 1435 1.30 1.30 42.36
348 Hungary | 2785 2.51 2.51 44.87
: | : : : :
498 Moldova | 1211 1.09 1.09 58.48
499 Montenegro | 2184 1.97 1.97 60.45
528 Netherlands | 3668 3.31 3.31 63.76
578 Norway | 2169 1.96 1.96 65.72
616 Poland | 2453 2.21 2.21 67.93
620 Portugal | 2354 2.13 2.13 70.06
642 Romania | 2524 2.28 2.28 72.34
643 Russia | 2679 2.42 2.42 74.76
688 Serbia | 2559 2.31 2.31 77.07
703 Slovakia | 2565 2.32 2.32 79.38
705 Slovenia | 2235 2.02 2.02 81.40
724 Spain | 2455 2.22 2.22 83.62
752 Sweden | 2103 1.90 1.90 85.52
756 Switzerland | 4275 3.86 3.86 89.38
792 Turkey | 2069 1.87 1.87 91.24
804 Ukraine | 2420 2.18 2.18 93.43
807 North Macedonia | 2211 2.00 2.00 95.43
826 Great Britain | 3185 2.88 2.88 98.30
909 Northern Ireland | 435 0.39 0.39 98.69
915 Kosovo | 1447 1.31 1.31 100.00
Total | 110759 100.00 100.00
--------------------------------------------------------------------------------
.
. oneway immfactor country if immfactor ~= .,tab
Country |
(ISO 3166-1 | Summary of takejobs crime
Numeric | strainwelfare owncustoms
code) | Mean Std. Dev. Freq.
------------+------------------------------------
Albania | .52663247 .91669659 2,486
Azerbaij | .41242884 .75825759 1,448
Austria | -.34499898 .82297632 3,008
Armenia | .47523728 .74669216 2,706
Belgium | -.1342983 .75448219 1,488
Bosnia a | .04688463 .87830355 2,828
Bulgaria | -.23307162 .8599487 2,218
Belarus | -.02267476 .80367539 2,654
Croatia | .0175983 .85663715 2,681
Cyprus | -.56812984 .67338488 865
Northern | .23387116 1.0856686 452
Czech Re | -.41091566 .76977594 3,242
Denmark | -.04507802 .7441623 4,764
Estonia | -.08617654 .81005037 2,451
Finland | .06322009 .80574298 2,166
France | .26902951 .86031816 3,138
Georgia | .31850699 .93294149 2,858
Germany | -.16651872 .80024392 4,024
Greece | -.22786174 .81861355 1,435
Hungary | -.45008144 .79610421 2,785
Iceland | .47686534 .82023629 2,289
Ireland | -.2192179 .77487173 883
Italy | -.10612937 .83259777 3,303
Latvia | -.09514977 .74734859 2,348
Lithuani | -.16750899 .7170314 2,245
Luxembou | .26496319 .83185921 1,485
Malta | -.64797945 .60866197 1,308
Moldova | .12054501 .8428975 1,211
Monteneg | .22367822 .93590782 2,184
Netherla | .01379921 .75027059 3,668
Norway | -.03188767 .68567194 2,169
Poland | .12792221 .82211202 2,453
Portugal | .12159486 .7656805 2,354
Romania | .22670131 .96556158 2,524
Russia | -.24134028 .80454117 2,679
Serbia | -.06846114 .8731876 2,559
Slovakia | -.30673834 .7192112 2,565
Slovenia | -.01288831 .8123877 2,235
Spain | .26190901 .83062315 2,455
Sweden | .25258097 .87624981 2,103
Switzerl | .00209355 .77800164 4,275
Turkey | -.14600297 .84818332 2,069
Ukraine | .09837232 .85107846 2,420
North Ma | .18620844 1.0048139 2,211
Great Br | .04780672 .90185018 3,185
Northern | -.28429996 .76353595 435
Kosovo | -.17869994 .82166866 1,447
------------+------------------------------------
Total | -8.004e-10 .85779265 110,759
Analysis of Variance
Source SS df MS F Prob > F
------------------------------------------------------------------------
Between groups 6833.32589 46 148.550563 220.27 0.0000
Within groups 74663.3221 110712 .674392316
------------------------------------------------------------------------
Total 81496.648 110758 .735808231
Bartlett's test for equal variances: chi2(46) = 1.8e+03 Prob>chi2 = 0.000
. gen x = 1 if immfactor ~= .
(113,675 missing values generated)
.
.
. drop * i x
i ambiguous abbreviation
r(111);
.
.
.
.
.
.
.
.
. drop * if x
invalid syntax
r(198);
. drop * if x
invalid syntax
r(198);
.
.
.
.
.
.
. drop * if x ~= 1
invalid syntax
r(198);
. fre x
x
-------------------------------------------------------
| Freq. Percent Valid Cum.
----------+--------------------------------------------
Valid 1 | 110759 49.35 100.00 100.00
Missing . | 113675 50.65
Total | 224434 100.00
-------------------------------------------------------
. replace x = 0 if x ~= 1
(113,675 real changes made)
. fre x
x
-----------------------------------------------------------
| Freq. Percent Valid Cum.
--------------+--------------------------------------------
Valid 0 | 113675 50.65 50.65 50.65
1 | 110759 49.35 49.35 100.00
Total | 224434 100.00 100.00
-----------------------------------------------------------
. drop * if x == 0
invalid syntax
r(198);
. drop immfator if x == 0
variable immfator not found
r(111);
. drop immfactor if x == 0
invalid syntax
r(198);
. drop immfactor if x ~= 1
invalid syntax
r(198);
This seems to follow the manualbut I cannot delete the observations. What did I do wrong? Any help would be appreciated, Thanks,
Ric Uslaner
.

Comment