Dear Profs and colleagues,
I am, going to compute the total number of immigrants based on nacio which shows the nationality of individuals. Since the nacio is a string variable I made a variable immigrant which has a value 1 (immigrants).
I did this syntax but something is wrong. Because the total number of immigrants is 145,165 while
num_immi generates very large values, larger than total number of immigrants.
Any ideas are appreciated. I really have no idea whats wrong here.
Cheers,
Paris
I am, going to compute the total number of immigrants based on nacio which shows the nationality of individuals. Since the nacio is a string variable I made a variable immigrant which has a value 1 (immigrants).
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float immigrant str6 nacio 1 "ES" 1 "RO" 1 "UA" 1 "CV" 1 "GW" 1 "UA" 1 "CV" 1 "FR" 1 "BR" 1 "GW" 1 "BR" 1 "BG" 1 "AO" 1 "CV" 1 "BR" 1 "CV" 1 "RO" 1 "GN" 1 "CV" 1 "BR" 1 "CV" 1 "BR" 1 "GE" 1 "CV" 1 "UA" 1 "BR" 1 "UA" 1 "BR" 1 "BR" 1 "GN" 1 "UA" 1 "CV" 1 "MD" 1 "CV" 1 "GW" 1 "GW" 1 "BR" 1 "CV" 1 "DE" 1 "BR" 1 "AP" 1 "MD" 1 "RO" 1 "MD" 1 "CV" 1 "RO" 1 "RO" 1 "ST" 1 "CN" 1 "BR" 1 "RU" 1 "GW" 1 "CV" 1 "CV" 1 "BR" 1 "UA" 1 "AO" 1 "IN" 1 "UA" 1 "MD" 1 "MD" 1 "BR" 1 "ST" 1 "BR" 1 "MD" 1 "RO" 1 "BR" 1 "GN" 1 "BR" 1 "BR" 1 "UA" 1 "UA" 1 "RO" 1 "BE" 1 "UA" 1 "BR" 1 "BR" 1 "CV" 1 "RO" 1 "BR" 1 "BR" 1 "CV" 1 "FR" 1 "BR" 1 "UA" 1 "BR" 1 "AO" 1 "UA" 1 "CV" 1 "BR" 1 "CV" 1 "RO" 1 "BR" 1 "BR" 1 "CV" 1 "GW" 1 "BR" 1 "UA" 1 "BR" 1 "BR" end
num_immi generates very large values, larger than total number of immigrants.
Code:
egen num_immi = total(immigrant), by(nacio )
. tab immigrant
immigrant | Freq. Percent Cum.
------------+-----------------------------------
1 | 145,165 100.00 100.00
------------+-----------------------------------
Total | 145,165 100.00
. sum num_immi
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------------
num_immi | 145,165 17948.51 16001.13 1 41610
end
Cheers,
Paris

Comment