Statalist


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

st: HOW TO RUN A DOUBLE TEST


From   "Solorzano, Jenniffer" <JENNIFFERS@Contractual.iadb.org>
To   statalist@hsphsun2.harvard.edu
Subject   st: HOW TO RUN A DOUBLE TEST
Date   Thu, 4 Sep 2008 16:24:29 -0400

I need run a program twice but at the same time. I only need to change a
variable, so I can see a table with two outcomes but with differences
between them because the variable I have changed.

I need that the program below give me results at the same time when I
use beneficiario1 and when I use beneficiario.

g lineab= 8.171677 if porcentajedepobreza <= 20 & AREA==1
replace lineab= 8.175466 if porcentajedepobreza <= 20 & AREA==2
replace lineab= 8.284554 if (porcentajedepobreza >= 21 &
porcentajedepobreza <= 40) & AREA==1
replace lineab= 8.285877 if (porcentajedepobreza >= 21 &
porcentajedepobreza <= 40) & AREA==2
replace lineab= 8.416035 if (porcentajedepobreza >= 41 &
porcentajedepobreza <= 100) & AREA==1
replace lineab= 8.414929 if (porcentajedepobreza >= 41 &
porcentajedepobreza <= 100) & AREA==2


g beneficiario1  = (indice < lineab) & lineab!=.


g lineaa= 8.416035 if porcentajedepobrezag <= 29 & AREA==1
replace lineaa= 8.414929 if porcentajedepobrezag <= 29 & AREA==2
replace lineaa= 8.284554 if (porcentajedepobrezag >= 30 &
porcentajedepobrezag <= 59) & AREA==1
replace lineaa= 8.285877 if (porcentajedepobrezag >= 30 &
porcentajedepobrezag <= 59) & AREA==2
replace lineaa= 8.171677 if (porcentajedepobrezag >= 60 &
porcentajedepobrezag <= 95) & AREA==1
replace lineaa= 8.175466 if (porcentajedepobrezag >= 60 &
porcentajedepobrezag <= 95) & AREA==2

g beneficiario  = (indice < lineaa) & lineaa!=.


replace fex = round(fex)

sum beneficiario1 [w=fex] if PPA05==1
set seed 1234567
g aleatorio = uniform() 
sort aleatorio
g selec = sum(fex) if beneficiario1==1 & PPA05==1
replace selec = 0  if PPA05==1 & (selec * 100 / r(sum)) > `alcance'
recode selec (1/max=1) (0=0) 
egen select=mean(selec), by(NUM_HOG)

* TRANSFERENCIAS ACTTUALES
g transf11 = `transfa1' if n`n1'==1 & n`n2'==0 & beneficiario1==1 &
mun_pri_`muni'==1 & PPA05==1 & select==1
g transf12 = `transfe1' if ((n`n1'==0 & n`n2'==1) | (n`n1'==1 &
n`n2'==1)) & beneficiario1==1 & mun_pri_`muni'==1 & PPA05==1 & select==1
recode transf11 transf12 (.=0)
g transf1 = transf11 + transf12

* TRANSFERENCIAS ESCALONADAS
g transf21 = `transfa2'  if ((n`n1'==1 & n`n2'==0) | (n`n1'==1 &
n`n2'==1)) & beneficiario1==1 & mun_pri_`muni'==1 & PPA05==1 & select==1
g transf2f = `transfe2'  if ((n`n1'==0 & n`n2'==1) | (n`n1'==1 &
n`n2'==1)) & beneficiario1==1 & mun_pri_`muni'==1 & PPA05==1 & select==1

g p6_15 = PPA03>=6 & PPA03<=15
g p7_15 = PPA03>=7 & PPA03<=15

g temp1    = `transfe20' if (p`n2'==1) & anoesa==0 & beneficiario1==1 &
mun_pri_`muni'==1 & select==1
g temp2    = `transfe21' if (p`n2'==1) & anoesa==1 & beneficiario1==1 &
mun_pri_`muni'==1 & select==1
g temp3    = `transfe22' if (p`n2'==1) & anoesa==2 & beneficiario1==1 &
mun_pri_`muni'==1 & select==1
g temp4    = `transfe23' if (p`n2'==1) & anoesa==3 & beneficiario1==1 &
mun_pri_`muni'==1 & select==1
g temp5    = `transfe24' if (p`n2'==1) & anoesa==4 & beneficiario1==1 &
mun_pri_`muni'==1 & select==1
g temp6    = `transfe25' if (p`n2'==1) & anoesa==5 & beneficiario1==1 &
mun_pri_`muni'==1 & select==1
g temp7    = `transfe26' if (p`n2'==1) & anoesa>=6 & beneficiario1==1 &
mun_pri_`muni'==1 & select==1
recode  transf21 transf2f temp1-temp7 (.=0)
g temp = temp1+temp2+temp3+temp4+temp5+temp6+temp7
egen transf22 = sum(temp), by(NUM_HOG)
*replace transf22 = `maxxhog' if transf22 > `maxxhog'
g transf2 = transf21 + transf2f + transf22 if  PPA05==1
recode transf2 (.=0)
replace transf2 = `maxxhog' if transf2 > `maxxhog'
drop temp1-temp7 selec transf11 transf12 transf21 transf22 temp

I need that beneficiario variable can be different 


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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