The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Dataset use in Stata » Merging SPA datasets- Nepal SPA 2015
Re: Merging SPA datasets- Nepal SPA 2015 [message #14056 is a reply to message #14037] Wed, 07 February 2018 20:33 Go to previous messageGo to previous message
rkchettri is currently offline  rkchettri
Messages: 19
Registered: November 2017
Member
Thank you, Wang, for ideas and command. I want to do same what you mentioned.
I tried with your code and it worked for a single variable at a time. When I tried to recode and run but it did not work. Actually, I want to recode and run all ANC/ delivery training variables and want to merge with health facility dataset.

Here is the code that I worked to identify collapse variables of two ANC training, these codes work when I run one at a time but not working when I run together. Is any ideas to collapse all training related variables at a single entry?. I have 20 training variables that I want to recode per facility.

gen tp502rec_1=0
replace tp502rec_1 = 1 if p502_1==1
collapse (mean) per_tp502rec_1=tp502rec_1 [pw=provwt], by(facil)
recode per_tp502rec_1 0=0 .=0 0.00001/max=1, gen( p502rec_1)
codebook p502rec_1

gen tp502rec_2=0
replace tp502rec_2 = 1 if p502_2==1
collapse (mean) per_tp502rec_2=tp502rec_2 [pw=provwt], by(facil)
recode per_tp502rec_2 0=0 .=0 0.00001/max=1, gen( p502rec_2)
codebook p502rec_2
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Declaring my Data Survey Data
Next Topic: Women's decision making power
Goto Forum:
  


Current Time: Sun Apr 28 21:44:47 Coordinated Universal Time 2024