|
|
|
|
************************************************************************************************************
|
|
|
|
|
* Estpop : Estimation de la population d'une commune, d'un canton, d'un d<>partement de la r<>gion Centre
|
|
|
|
|
* (ou de la r<>gion Centre toute enti<74>re)
|
|
|
|
|
*
|
|
|
|
|
* Version 2.1: 7 d<>cembre 2004
|
|
|
|
|
* Version 2: 2 d<>cembre 2004
|
|
|
|
|
* Version 1.5: 2 d<>cembre 2004
|
|
|
|
|
* Version 1.4: 21 octobre 2004
|
|
|
|
|
* Version 1.3: 16 aout 2004
|
|
|
|
|
* Version 1.2: 20 juillet 2004
|
|
|
|
|
* Version 1.1: 16 juillet 2004
|
|
|
|
|
* Version 1: 16 juillet 2004
|
|
|
|
|
*
|
|
|
|
|
* Jean-benoit Hardouin, Observatoire R<>gional de la Sant<6E> du Centre - Orl<72>ans - France
|
|
|
|
|
* jean-benoit.hardouin@neuf.fr
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2004 Jean-Benoit Hardouin
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************************************
|
|
|
|
|
|
|
|
|
|
program define estpop,rclass
|
|
|
|
|
version 7.0
|
|
|
|
|
syntax , [annee(int 1999) codegeo(int 1) sexe(int 0) quinq juillet]
|
|
|
|
|
capture su *
|
|
|
|
|
if _rc==0 {
|
|
|
|
|
tempfile saveestpop
|
|
|
|
|
qui save `saveestpop',replace
|
|
|
|
|
}
|
|
|
|
|
preserve
|
|
|
|
|
|
|
|
|
|
if `annee'>=1900&`annee'<2000 {
|
|
|
|
|
local annee=`annee'-1900
|
|
|
|
|
}
|
|
|
|
|
local sannee=1900+`annee'
|
|
|
|
|
if `sannee'<1982 {
|
|
|
|
|
local `sannee'=`sannee'+100
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if `annee'<82|`annee'>99 {
|
|
|
|
|
di in red "Vous devez indiquer une annee entre 1982 et 1999 (ou entre 82 et 99)"
|
|
|
|
|
exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if `sexe'==0 {
|
|
|
|
|
local sexel hf
|
|
|
|
|
}
|
|
|
|
|
else if `sexe'==1 {
|
|
|
|
|
local sexel h
|
|
|
|
|
}
|
|
|
|
|
else if `sexe'==2 {
|
|
|
|
|
local sexel f
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
di in red "Vous devez indiquer un sexe parmi 0 (2 sexes confondus), 1 (hommes) et 2 (femmes)"
|
|
|
|
|
exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if `codegeo'>100 {/*SI COMMUNE OU ZE OU CANTON */
|
|
|
|
|
use "C:\ado\personal\files\rp`sexel'829099.dta", clear
|
|
|
|
|
sort codecom
|
|
|
|
|
merge codecom using "C:\ado\personal\files\nais8002.dta"
|
|
|
|
|
|
|
|
|
|
if `sexe'!=0 {
|
|
|
|
|
foreach i of numlist 80/99 00/02 {
|
|
|
|
|
if `sexe'==1 {
|
|
|
|
|
local ratio=1.05/2.05
|
|
|
|
|
}
|
|
|
|
|
else if `sexe'==2 {
|
|
|
|
|
local ratio=1/2.05
|
|
|
|
|
}
|
|
|
|
|
if `i'<10 {
|
|
|
|
|
qui replace naiss0`i'=naiss0`i'*`ratio'
|
|
|
|
|
}
|
|
|
|
|
else if `i'>=10 {
|
|
|
|
|
qui replace naiss`i'=naiss`i'*`ratio'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tempvar flag
|
|
|
|
|
gen `flag'=0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if `codegeo'==0 {
|
|
|
|
|
qui replace `flag'=1 if codecom==0
|
|
|
|
|
}
|
|
|
|
|
if `codegeo'==1 {
|
|
|
|
|
qui replace `flag'=1 if codecom!=0
|
|
|
|
|
}
|
|
|
|
|
if `codegeo'<100 {
|
|
|
|
|
qui replace `flag'=1 if dep==`codegeo'
|
|
|
|
|
}
|
|
|
|
|
if `codegeo'<1000&`codegeo'>100 {
|
|
|
|
|
qui replace `flag'=1 if arr==`codegeo'
|
|
|
|
|
}
|
|
|
|
|
if `codegeo'<10000&`codegeo'>1000&int(`codegeo'/100)!=24 {
|
|
|
|
|
qui replace `flag'=1 if pct==`codegeo'
|
|
|
|
|
}
|
|
|
|
|
if int(`codegeo'/100)==24 {
|
|
|
|
|
qui replace `flag'=1 if ze94==`codegeo'
|
|
|
|
|
}
|
|
|
|
|
if `codegeo'<100000&`codegeo'>10000 {
|
|
|
|
|
qui replace `flag'=1 if codecom==`codegeo'
|
|
|
|
|
}
|
|
|
|
|
qui keep if `flag'==1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if `annee'==82|`annee'==90|`annee'==99 {
|
|
|
|
|
forvalues i=1/95 {
|
|
|
|
|
qui su rp`annee'`sexel'`i'
|
|
|
|
|
local popr`i'=r(sum)
|
|
|
|
|
return scalar popr`i'=`popr`i''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (`annee'>90&`annee'<99)|(`annee'>82&`annee'<90) {
|
|
|
|
|
if `annee'>90&`annee'<99 {
|
|
|
|
|
local first=`annee'-90
|
|
|
|
|
local last=98-`annee'
|
|
|
|
|
local anc=90
|
|
|
|
|
local suiv=99
|
|
|
|
|
local nbans=9
|
|
|
|
|
}
|
|
|
|
|
if `annee'>82&`annee'<90 {
|
|
|
|
|
local first=`annee'-82
|
|
|
|
|
local last=89-`annee'
|
|
|
|
|
local anc=82
|
|
|
|
|
local suiv=90
|
|
|
|
|
local nbans=8
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
forvalues i=1/`first' {
|
|
|
|
|
local tmp=`suiv'-`annee'+`i'
|
|
|
|
|
local tmp2=`suiv'-`annee'+1
|
|
|
|
|
tempvar rp`annee'`sexel'`i'
|
|
|
|
|
qui gen `rp`annee'`sexel'`i''=naiss`=`annee'-`i''+`i'*(rp`suiv'`sexel'`tmp'-naiss`=`annee'-`i'')/`tmp'
|
|
|
|
|
qui su `rp`annee'`sexel'`i''
|
|
|
|
|
local popr`i'=r(sum)
|
|
|
|
|
return scalar popr`i'=`popr`i''
|
|
|
|
|
}
|
|
|
|
|
local rp`annee'`sexel'94 rp`annee'`sexel'95
|
|
|
|
|
forvalues i=`=`anc'+1'/`=`suiv'-1' {
|
|
|
|
|
tempname rp`i'`sexel'94 rp`i'`sexel'95
|
|
|
|
|
qui gen `rp`i'`sexel'94'=rp`anc'`sexel'94+(rp`suiv'`sexel'94-rp`anc'`sexel'94)/`nbans'*(`i'-`anc')
|
|
|
|
|
qui gen `rp`i'`sexel'95'=rp`anc'`sexel'95+(rp`suiv'`sexel'95-rp`anc'`sexel'95)/`nbans'*(`i'-`anc')
|
|
|
|
|
}
|
|
|
|
|
qui su `rp`annee'`sexel'94'
|
|
|
|
|
local popr94=r(sum)
|
|
|
|
|
return scalar popr94=`popr94'
|
|
|
|
|
qui su `rp`annee'`sexel'95'
|
|
|
|
|
local popr95=r(sum)
|
|
|
|
|
return scalar popr95=`popr95'
|
|
|
|
|
forvalues i=`=`first'+1'/`=95-`nbans'' {
|
|
|
|
|
tempvar rp`annee'`sexel'`i'
|
|
|
|
|
local tmp=`anc'+`i'-`annee'
|
|
|
|
|
local tmp2=`suiv'+`i'-`annee'
|
|
|
|
|
qui gen `rp`annee'`sexel'`i''=rp`anc'`sexel'`tmp'+(`annee'-`anc')*(rp`suiv'`sexel'`tmp2'-rp`anc'`sexel'`tmp')/`nbans'
|
|
|
|
|
qui su `rp`annee'`sexel'`i''
|
|
|
|
|
local popr`i'=r(sum)
|
|
|
|
|
return scalar popr`i'=`popr`i''
|
|
|
|
|
}
|
|
|
|
|
forvalues i=`=95-`nbans'+1'/93 {
|
|
|
|
|
tempvar rp`annee'`sexel'`i'
|
|
|
|
|
local tmp=`anc'+`i'-`annee'
|
|
|
|
|
local tmp2=94-`i'+`annee'
|
|
|
|
|
qui gen `rp`annee'`sexel'`i''=rp`anc'`sexel'`tmp'+`=`annee'-`anc''*(`rp`tmp2'`sexel'94'-rp`anc'`sexel'`tmp')/`=`tmp2'-`anc''
|
|
|
|
|
qui su `rp`annee'`sexel'`i''
|
|
|
|
|
local popr`i'=r(sum)
|
|
|
|
|
return scalar popr`i'=`popr`i''
|
|
|
|
|
}
|
|
|
|
|
/*qui su naiss`annee'
|
|
|
|
|
local popr0=r(sum)
|
|
|
|
|
return scalar popr0=`popr0'*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
qui su naiss`annee'
|
|
|
|
|
local popr0=r(sum)
|
|
|
|
|
|
|
|
|
|
return scalar popr0=`popr0'
|
|
|
|
|
}/*FIN SI COMMUNE ZE OU CANTON OU ANNEE<1990*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else if `codegeo'<100 { /*FRANCE, REGION OU DEPT*/
|
|
|
|
|
use "C:\ado\personal\files\popfrregdept8201.dta", clear
|
|
|
|
|
if `sexe'==0 {
|
|
|
|
|
replace sexe=0
|
|
|
|
|
}
|
|
|
|
|
if "`juillet'"=="" {
|
|
|
|
|
forvalues i=0/95 {
|
|
|
|
|
qui su age`i' if annee==`sannee'&codegeo==`codegeo'&sexe==`sexe'
|
|
|
|
|
local popr`i'=r(sum)
|
|
|
|
|
return scalar popr`i'=`popr`i''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if "`juillet'"!="" {
|
|
|
|
|
local pannee=`sannee'+1
|
|
|
|
|
forvalues i=0/95 {
|
|
|
|
|
qui su age`i' if annee==`pannee'&codegeo==`codegeo'&sexe==`sexe'
|
|
|
|
|
local poppr`i'=r(sum)
|
|
|
|
|
qui su age`i' if annee==`sannee'&codegeo==`codegeo'&sexe==`sexe'
|
|
|
|
|
local popsr`i'=r(sum)
|
|
|
|
|
local popr`i'=(`poppr`i''+`popsr`i'')/2
|
|
|
|
|
return scalar popr`i'=`popr`i''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}/*FIN FRANCE, REGION OU DEPT ET ANNEE>=1990*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local popr=0
|
|
|
|
|
forvalues i=0/95 {
|
|
|
|
|
local popr=`popr'+`popr`i''
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return scalar popr=`popr'
|
|
|
|
|
local poprq1=`popr1'+`popr2'+`popr3'+`popr4'
|
|
|
|
|
return scalar poprq1=`poprq1'
|
|
|
|
|
|
|
|
|
|
foreach i of numlist 5(5)90 {
|
|
|
|
|
local poprq`i'=`popr`i''+`popr`=`i'+1''+`popr`=`i'+2''+`popr`=`i'+3''+`popr`=`i'+4''
|
|
|
|
|
return scalar poprq`i'=`poprq`i''
|
|
|
|
|
}
|
|
|
|
|
return scalar poprq0=`popr0'
|
|
|
|
|
return scalar poprq95=`popr95'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if `codegeo'==0 {
|
|
|
|
|
local libgeo France metropolitaine
|
|
|
|
|
}
|
|
|
|
|
else if `codegeo'==1 {
|
|
|
|
|
local libgeo Region Centre
|
|
|
|
|
}
|
|
|
|
|
else if `codegeo'==18 {
|
|
|
|
|
local libgeo Cher
|
|
|
|
|
}
|
|
|
|
|
else if `codegeo'==28 {
|
|
|
|
|
local libgeo Eure-et-Loir
|
|
|
|
|
}
|
|
|
|
|
else if `codegeo'==36 {
|
|
|
|
|
local libgeo Indre
|
|
|
|
|
}
|
|
|
|
|
else if `codegeo'==37 {
|
|
|
|
|
local libgeo Indre-et-Loire
|
|
|
|
|
}
|
|
|
|
|
else if `codegeo'==41 {
|
|
|
|
|
local libgeo Loir-et-Cher
|
|
|
|
|
}
|
|
|
|
|
else if `codegeo'==45 {
|
|
|
|
|
local libgeo Loiret
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
qui trouve `codegeo'
|
|
|
|
|
local libgeo=r(trouve`codegeo')
|
|
|
|
|
}
|
|
|
|
|
di
|
|
|
|
|
if `codegeo'>1000&`codegeo'<10000 {
|
|
|
|
|
di in green "Niveau geographique : Canton de " in yellow "`libgeo'"
|
|
|
|
|
}
|
|
|
|
|
else if `codegeo'>10000&`codegeo'<100000 {
|
|
|
|
|
di in green "Niveau geographique : Commune de " in yellow "`libgeo'"
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
di in green "Niveau geographique : " in yellow "`libgeo'"
|
|
|
|
|
}
|
|
|
|
|
if `sexe'==0 {
|
|
|
|
|
local libsexe Deux sexes
|
|
|
|
|
}
|
|
|
|
|
else if `sexe'==1 {
|
|
|
|
|
local libsexe Hommes
|
|
|
|
|
}
|
|
|
|
|
else if `sexe'==2 {
|
|
|
|
|
local libsexe Femmes
|
|
|
|
|
}
|
|
|
|
|
if "`juillet'"==""&`codegeo'<100{
|
|
|
|
|
local comm="Estimation au 1er janvier"
|
|
|
|
|
}
|
|
|
|
|
else if "`juillet'"!=""&`codegeo'<100{
|
|
|
|
|
local comm="Estimation au 1er juillet"
|
|
|
|
|
}
|
|
|
|
|
else if `codegeo'>100 {
|
|
|
|
|
local comm="Retropolation entre deux recensements pour"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
di in green "Sexe : " in yellow "`libsexe'"
|
|
|
|
|
di in green "Annee : " in yellow "`comm' `=`annee'+1900'"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
di
|
|
|
|
|
di in green _col(4) "{hline 22}"
|
|
|
|
|
di in green _col(4) "Age" _col(16) "Population"
|
|
|
|
|
di in green _col(4) "{hline 22}"
|
|
|
|
|
if "`quinq'"=="" {
|
|
|
|
|
forvalues i=0/95 {
|
|
|
|
|
if `i'<2 {
|
|
|
|
|
di in green _col(4) "`i' an" _col(18) in yellow %8.0f `popr`i''
|
|
|
|
|
}
|
|
|
|
|
else if `i'==95 {
|
|
|
|
|
di in green _col(4) "95 ans et plus" _col(18) in yellow %8.0f `popr`i''
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
di in green _col(4) "`i' ans" _col(18) in yellow %8.0f `popr`i''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
di in green _col(4) "0 an" _col(18) in yellow %8.0f `popr0'
|
|
|
|
|
di in green _col(4) "1-4 ans" _col(18) in yellow %8.0f `poprq1'
|
|
|
|
|
|
|
|
|
|
foreach i of numlist 5(5)90 {
|
|
|
|
|
di in green _col(4) "`i'-`=`i'+4' ans" _col(18) in yellow %8.0f `poprq`i''
|
|
|
|
|
}
|
|
|
|
|
di in green _col(4) "95 ans et plus" _col(18) in yellow %8.0f `popr95'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
di in green _col(4) "{hline 22}"
|
|
|
|
|
di in green _col(4) "Total" _col(18) in yellow %8.0f `popr'
|
|
|
|
|
|
|
|
|
|
restore , not
|
|
|
|
|
qui drop _all
|
|
|
|
|
if "`saveestpop'"!="" {
|
|
|
|
|
qui use `saveestpop'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|