Hi everyone,
I am new to this forum and Stata. I wonder if there is a trick/command which performs similar to the COUNTIF function in excel?
I tried to looked up on the help file and internet but without luck. My purpose is to count the share of foreigners to the total population each year (30 years time series).
"
gen nationality = 1 if nation = 1
replace nationality = 0 if inrange(nation,121,997) /*values between 121 to 997 are the nationalities of the foreigners*/
replace nationality = . if nation = 998 /*unknown nationality*/
label variable nationality "Nationality"
label define nationality 1 "Natives" 0 "Immigrants"
"
Would be grateful if any of you could give me a hint.
Thanks a lot.
I am new to this forum and Stata. I wonder if there is a trick/command which performs similar to the COUNTIF function in excel?
I tried to looked up on the help file and internet but without luck. My purpose is to count the share of foreigners to the total population each year (30 years time series).
"
gen nationality = 1 if nation = 1
replace nationality = 0 if inrange(nation,121,997) /*values between 121 to 997 are the nationalities of the foreigners*/
replace nationality = . if nation = 998 /*unknown nationality*/
label variable nationality "Nationality"
label define nationality 1 "Natives" 0 "Immigrants"
"
Would be grateful if any of you could give me a hint.
Thanks a lot.
Comment