Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: weight and easier way


From   "Sebastian Kruk" <[email protected]>
To   [email protected]
Subject   st: RE: weight and easier way
Date   Thu, 12 Jul 2007 08:39:58 -0300

Hi dear statalist users,

I have been in vacation but I work anyway.

Do you remember my problem?

I have a households survey and population proyections.

All the weights are wrong.

Some of my varriables are:

anio	correlativ	dpto	secc	ccz	segm	mes
estrato	pesoan	pesosem	pesotri	nper	e1	e2	e3
e4	e5	e5_1	e5_2	e5_3	e5_4	e5_5
e5_6_1	e5_6_2	e6	e6_1_1	e6_1_2	e6_1_3	e7	e8_1	e8_2	e8_3	e8_4_1	e8_1_1	e8_1_2	e8_1_3	e9	e10	e11_1	e11_2	e11_3	e11_4	e11_4_1	e11_5	e11_6	e12_2	e13	e14	pobpcoac	f1_1	f1_2	f2	f3	f4	f5_2	f6_2	f7	f8	f9_1	f10_1	f10_2	f11_2	f12_2	f13	f14	f15_1	f16_1	f16_2	f17_1	f17_2	f18	f19	f20	f21	f22	f23	f24	f25	f26	f27	f28	f29	f30	f31	f32	f33	f34	f35	f36	f37_2	f38_2	f39	f40_1	f40_2	f40_3	f40_4	f40_5	g1_1_1	g1_1_2	g1_1_3	g1_1_4	g1_1_5	g1_1_6	g1_1_7	g1_1_8	g1_1_9	g1_2_1	g1_2_2	g1_2_3	g1_2_4	g1_2_5	g1_2_6	g1_2_7	g1_2_8	g1_2_9	g2_1	g2_2	g2_3	g3_1	g3_2	g3_3	g3_4	g3_5	g3_6	g3_7	g3_8	g3_9_1	g3_9_2	g4_1_1	g4_1_2	g4_2_1	g4_2_2	g4_2_3	g4_2_4	g4_2_5	g4_2_6	g5_1	g5_2	g5_3	g5_4	g5_5	g5_6	g5_7	g5_8	g5_9	g5_10	g5_11	pt1	pt2	pt4	noregp	norego	subempl	monto1	monto2	locech	nomlocech	barrio	nombre	ht11	ht13	ht19	_merge	pond	nuev_pond	smn	m65	ad_may	adulto_may	may60	may65	may70	ing_pc	ipc	ing_pc_def	quintil	quintil2	equiv	n	ing_equiv	ing_equiv_pc	quintil_eq	quintil_eq2	par1	par2	par3	par4	par5	par6	par7	par8	par9	p!
ar10	par11	espos	hijo	hijot	padsue	nieto	otfam	yerno	nopar	tiphog	cba02	indi02	lpine2	pobine02	lp96	cba96	pobine	indi	e_jefe	eda_jefe	ed_18_24	ed_25_29	ed_30_39	ed_40_49	ed_50_59	ed_más60	edad_jefe	c_lab	cond_lab	asign	asig_fam	mayor60	mayor65	mayor70	s_desemp	seg_desemp	transf	transf_9	transf_1	transf_2	transf_3	transf_4	transf_5	transf_6	transf_7	transf_8	monto_transf	jubilado	pension	jubiladoh	pensionh	asigna	asignasu	affam	benef	benefsu	benefh	men15	men15h	men15sum	men18	menor18	menor18h	men6	men6h	men6sum	men7	men7h	men7sum	asiprim	asipsum	asites	asisec	asisecsu	trabjov	actjov	trabjh	actjh	formal	formalh	ocupfor	ocupformh	dessp	dessph	despp	despph	jubi95	jubi95h	jubi	jubih	prodru	prodruh	ylab	ylabh	ylabf3	ylabf3h	fran10	fran3	fran6	at16697	at16697h	at16697s	ben	behipoh	behipos	elegible	elegible2	eleg1	eleg2	eleg1se	eleg2se	ben2	behipoh2	eleg22	ypc_sv	agegp	n_h_0	n_h_1	n_h_5	n_h_10	n_h_15	n_h_20	n_h_25	n_h_30	n_h_35	n_h_40	n_h_45	n_h_50	n_h_55	n_h_60	n_h_65	n_h_70	n_h_7!
5	n_h_80	n_h_85	n_h_90	n_h_95	h_dpto	h_1_p	corrector	vaa
2005	1	1	1	1	1	4	3	39	79	158	1	2	58	1	3	0	2	2	2	2	1	2	0	0	3	0	0	1	0	0	0	0	4	0	0	0	1	0	6	6	0	0	0	2	638	2	1	2	1	0	0	0	2	3460	9199	1	4	1	1	1	1310	5239	6	1	1	2	2	40	12	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	2	2	2	2	1	4000	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	3000	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	2	0	0	0	0	0	0	0	0	0	0	7975	4974.93	7975	0	1	0	974.93	0	0101	MONTEVIDEO	01	CIUDAD
VIE	12175	2300	2	3	1.067	41.613	1363	0	0	0	0	0	0	6087.5	.992	6038.8	4	4	1	1.7	7161.765	7104.47	4	4	1	0	0	0	0	0	0	0	0	0	0	0	0	1	0	0	0	0	0	3	1126.07	0	3333.167	0	4176.69	1332.3	0	0	58	58	0	0	0	0	1	0	5	3	3	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	1	0	1	0	0	0	0	1	1	1	1	0	0	0	0	0	0	0	0	0	0	8750	8750	8750	8750	1	0	0	1	1	2	0	0	0	0	0	0	0	0	0	0	1	0	4937.5	55	165	647	950	1100	1107	1090	963	880	797	841	835	772	691	644	561	502	441	271	83	25	7	13372	643547		25290

Weights in microsurvey are wrong, It must be corrected by new one
using population proyections.

I do the next but I have problems using a loop.

*Make a categorical variable for group of age:

egen agegp=cut(e2), at
(0,1,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100)

*Put labels

label define agegp 0 "0" 1 "1-4" 5 "5-9" 10 "10-14" 15 "15-19" 20
"20-25" 25 "25-29" 30 "30-34" 35 "35-39" 40 "40-44" 45 "45-49" 50
"50-54" 55 "55-59" 60 "60-64" 65 "65-69" 70 "70-74" 75 "75-79" 80
"80-84" 85 "85-89" 90 "90-94" 95 "95+"

*Compute number of men by group of age and departamento (means state in English)

egen n_h_0=total(agegp==0 & e1==1), by (dpto)
egen n_h_1=total(agegp==1 & e1==1), by (dpto)
egen n_h_5=total(agegp==5 & e1==1), by (dpto)
egen n_h_10=total(agegp==10 & e1==1), by (dpto)
egen n_h_15=total(agegp==15 & e1==1), by (dpto)
egen n_h_20=total(agegp==20 & e1==1), by (dpto)
egen n_h_25=total(agegp==25 & e1==1), by (dpto)
egen n_h_30=total(agegp==30 & e1==1), by (dpto)
egen n_h_35=total(agegp==35 & e1==1), by (dpto)
egen n_h_40=total(agegp==40 & e1==1), by (dpto)
egen n_h_45=total(agegp==45 & e1==1), by (dpto)
egen n_h_50=total(agegp==50 & e1==1), by (dpto)
egen n_h_55=total(agegp==55 & e1==1), by (dpto)
egen n_h_60=total(agegp==60 & e1==1), by (dpto)
egen n_h_65=total(agegp==65 & e1==1), by (dpto)
egen n_h_70=total(agegp==70 & e1==1), by (dpto)
egen n_h_75=total(agegp==75 & e1==1), by (dpto)
egen n_h_80=total(agegp==80 & e1==1), by (dpto)
egen n_h_85=total(agegp==85 & e1==1), by (dpto)
egen n_h_90=total(agegp==90 & e1==1), by (dpto)
egen n_h_95=total(agegp==95 & e1==1), by (dpto)

*Computo total men by departemanto
egen h_dpto=rowtotal(n_h_*)

*Repit for women
egen n_m_0= total(agegp==0 & e1=!1), by (dpto)
…………………………………………………..
egen n_m_95=total(agegp==95 & e1=!1), by (dpto)
egen m_dpto=rowtotal(n_m_*)

*Make a constan equals men's proyection by departamento

gen h_1_p=643547
gen h_2_p=
…………………..
gen h_19_p=

*Repet for women
gen m_1_p=
gen m_2_p=
…………………..
gen m_19_p=

*Compute annual men expansor by departemanto
gen corrector=h_dpto/(h_1_p*n_h_0) if  e1==1 & agegp==0
replace corrector=h_dpto/(h_1_p*n_h_1) if  e1==1 & agegp==1
replace corrector=h_dpto/(h_1_p*n_h_5) if  e1==1 & agegp==5
replace corrector=h_dpto/(h_1_p*n_h_10) if  e1==1 & agegp==10
replace corrector=h_dpto/(h_1_p*n_h_15) if  e1==1 & agegp==15
replace corrector=h_dpto/(h_1_p*n_h_20) if  e1==1& agegp==20
replace corrector=h_dpto/(h_1_p*n_h_25) if  e1==1 & agegp==25
replace corrector=h_dpto/(h_1_p*n_h_30) if  e1==1& agegp==30
replace corrector=h_dpto/(h_1_p*n_h_35) if  e1==1 & agegp==35
replace corrector=h_dpto/(h_1_p*n_h_40) if  e1==1& agegp==40
replace corrector=h_dpto/(h_1_p*n_h_45) if  e1==1 & agegp==45
replace corrector=h_dpto/(h_1_p*n_h_50) if  e1==1& agegp==50
replace corrector=h_dpto/(h_1_p*n_h_55) if  e1==1 & agegp==55
replace corrector=h_dpto/(h_1_p*n_h_60) if  e1==1& agegp==60
replace corrector=h_dpto/(h_1_p*n_h_65) if  e1==1 & agegp==65
replace corrector=h_dpto/(h_1_p*n_h_70) if  e1==1& agegp==70
replace corrector=h_dpto/(h_1_p*n_h_75) if  e1==1 & agegp==75
replace corrector=h_dpto/(h_1_p*n_h_80) if  e1==1& agegp==80
replace corrector=h_dpto/(h_1_p*n_h_85) if  e1==1 & agegp==85
replace corrector=h_dpto/(h_1_p*n_h_90) if  e1==1& agegp==90
replace corrector=h_dpto/(h_1_p*n_h_95) if  e1==1 & agegp==95

*Repet for women
replace corrector=h_dpto/(h_1_p*n_h_0) if  e1==1

Bye,

Sebastian.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index