-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04_mom_health_datacleaning.do
1790 lines (1440 loc) · 67.4 KB
/
04_mom_health_datacleaning.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PROJECT: CPI - CHDN Nutrition Security Report
PURPOSE: Mother health dataset - data cleaning
AUTHOR: Nicholus
CREATED: 02 Dec 2019
MODIFIED:
THINGS TO DO:
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
** PREPARE DATASETS FOR DATA CLEA ING **
use "$dta/mom_dataset_combined.dta", clear
**-----------------------------------------------------**
** PREVIOUS U2 PREGNANCY
**-----------------------------------------------------**
**-----------------------------------------------------**
** ANC
**-----------------------------------------------------**
// ancpast_adopt
destring ancpast_adopt, replace
tab ancpast_adopt, m
drop if mi(ancpast_adopt) // non U2 hh members
// ancpast_yn
destring ancpast_yn, replace
replace ancpast_yn = .m if ancpast_adopt == 1
tab ancpast_yn, m
// ancpast_who
tab ancpast_who, m
local who ancpast_who1 ancpast_who2 ancpast_who3 ancpast_who4 ancpast_who5 ancpast_who6 ancpast_who7 ancpast_who8 ancpast_who9 ancpast_who10 ancpast_who11 ancpast_who888
foreach var in `who' {
destring `var', replace
//replace `var' = .m if ancpast_adopt == 1
tab `var', m
}
rename ancpast_who1 ancpast_spelist
rename ancpast_who2 ancpast_doc
rename ancpast_who3 ancpast_nurs
rename ancpast_who4 ancpast_ha
rename ancpast_who5 ancpast_pdoc
rename ancpast_who6 ancpast_lhv
rename ancpast_who7 ancpast_mw
rename ancpast_who8 ancpast_amw
rename ancpast_who9 ancpast_tba
rename ancpast_who10 ancpast_chw
rename ancpast_who11 ancpast_ehw
rename ancpast_who888 ancpast_oth
// ancpast_who_oth
// ancpast_spelist_where
destring ancpast_spelist_where, replace
replace ancpast_spelist_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_spelist_where_`x' = (ancpast_spelist_where == `x')
replace ancpast_spelist_where_`x' = .m if mi(ancpast_spelist_where)
tab ancpast_spelist_where_`x', m
}
rename ancpast_spelist_where_1 ancpast_spelist_home
rename ancpast_spelist_where_2 ancpast_spelist_hosp
rename ancpast_spelist_where_3 ancpast_spelist_clinic
rename ancpast_spelist_where_4 ancpast_spelist_rhc
rename ancpast_spelist_where_5 ancpast_spelist_vill
rename ancpast_spelist_where_6 ancpast_spelist_eho
rename ancpast_spelist_where_888 ancpast_spelist_othplc
// ancpast_spelist_where_oth
// ancpast_spelist_dist_dry ancpast_spelist_dist_wet
destring ancpast_spelist_dist_dry ancpast_spelist_dist_wet, replace
replace ancpast_spelist_dist_dry = .m if ancpast_adopt == 1
replace ancpast_spelist_dist_wet = .m if ancpast_adopt == 1
replace ancpast_spelist_dist_dry = .m if ancpast_spelist != 1
replace ancpast_spelist_dist_wet = .m if ancpast_spelist != 1
tab1 ancpast_spelist_dist_dry ancpast_spelist_dist_wet, m
// ancpast_spelist_visit ancpast_spelist_1tri_times ancpast_spelist_2tri_times ancpast_spelist_3tri_times
destring ancpast_spelist_visit ancpast_spelist_1tri_times ancpast_spelist_2tri_times ancpast_spelist_3tri_times, replace
replace ancpast_spelist_visit = .m if ancpast_adopt == 1
replace ancpast_spelist_visit = .m if ancpast_spelist != 1
replace ancpast_spelist_visit = .n if ancpast_spelist_visit == 444
replace ancpast_spelist_1tri_times = .m if mi(ancpast_spelist_visit)
replace ancpast_spelist_2tri_times = .m if mi(ancpast_spelist_visit)
replace ancpast_spelist_3tri_times = .m if mi(ancpast_spelist_visit)
replace ancpast_spelist_1tri_times = .n if ancpast_spelist_1tri_times == 444
replace ancpast_spelist_2tri_times = .n if ancpast_spelist_2tri_times == 444
replace ancpast_spelist_3tri_times = .n if ancpast_spelist_3tri_times == 444
tab1 ancpast_spelist_visit ancpast_spelist_1tri_times ancpast_spelist_2tri_times ancpast_spelist_3tri_times , m
// ancpast_doc_where
destring ancpast_doc_where, replace
replace ancpast_doc_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_doc_where_`x' = (ancpast_doc_where == `x')
replace ancpast_doc_where_`x' = .m if mi(ancpast_doc_where)
tab ancpast_doc_where_`x', m
}
rename ancpast_doc_where_1 ancpast_doc_home
rename ancpast_doc_where_2 ancpast_doc_hosp
rename ancpast_doc_where_3 ancpast_doc_clinic
rename ancpast_doc_where_4 ancpast_doc_rhc
rename ancpast_doc_where_5 ancpast_doc_vill
rename ancpast_doc_where_6 ancpast_doc_eho
rename ancpast_doc_where_888 ancpast_doc_othplc
// ancpast_doc_where_oth
// ancpast_doc_dist_dry ancpast_doc_dist_wet
destring ancpast_doc_dist_dry ancpast_doc_dist_wet , replace
replace ancpast_doc_dist_dry = .m if ancpast_adopt == 1
replace ancpast_doc_dist_wet = .m if ancpast_adopt == 1
replace ancpast_doc_dist_dry = .m if ancpast_doc != 1
replace ancpast_doc_dist_wet = .m if ancpast_doc != 1
tab1 ancpast_doc_dist_dry ancpast_doc_dist_wet , m
// ancpast_doc_visit ancpast_doc_1tri_times ancpast_doc_2tri_times ancpast_doc_3tri_times
destring ancpast_doc_visit ancpast_doc_1tri_times ancpast_doc_2tri_times ancpast_doc_3tri_times, replace
replace ancpast_doc_visit = .m if ancpast_adopt == 1
replace ancpast_doc_visit = .m if ancpast_doc != 1
replace ancpast_doc_visit = .n if ancpast_doc_visit == 444
replace ancpast_doc_1tri_times = .m if mi(ancpast_doc_visit)
replace ancpast_doc_2tri_times = .m if mi(ancpast_doc_visit)
replace ancpast_doc_3tri_times = .m if mi(ancpast_doc_visit)
replace ancpast_doc_1tri_times = .n if ancpast_doc_1tri_times == 444
replace ancpast_doc_2tri_times = .n if ancpast_doc_2tri_times == 444
replace ancpast_doc_3tri_times = .n if ancpast_doc_3tri_times == 444
tab1 ancpast_doc_visit ancpast_doc_1tri_times ancpast_doc_2tri_times ancpast_doc_3tri_times, m
// ancpast_nurs_where ancpast_nurs_where_oth ancpast_nurs_dist_dry ancpast_nurs_dist_wet ancpast_nurs_visit ancpast_nurs_1tri_times ancpast_nurs_2tri_times ancpast_nurs_3tri_times
destring ancpast_nurs_where, replace
replace ancpast_nurs_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_nurs_where_`x' = (ancpast_nurs_where == `x')
replace ancpast_nurs_where_`x' = .m if mi(ancpast_nurs_where)
tab ancpast_nurs_where_`x', m
}
rename ancpast_nurs_where_1 ancpast_nurs_home
rename ancpast_nurs_where_2 ancpast_nurs_hosp
rename ancpast_nurs_where_3 ancpast_nurs_clinic
rename ancpast_nurs_where_4 ancpast_nurs_rhc
rename ancpast_nurs_where_5 ancpast_nurs_vill
rename ancpast_nurs_where_6 ancpast_nurs_eho
rename ancpast_nurs_where_888 ancpast_nurs_othplc
// ancpast_nurs_where_oth
// ancpast_nurs_dist_dry ancpast_nurs_dist_wet
destring ancpast_nurs_dist_dry ancpast_nurs_dist_wet , replace
replace ancpast_nurs_dist_dry = .m if ancpast_adopt == 1
replace ancpast_nurs_dist_wet = .m if ancpast_adopt == 1
replace ancpast_nurs_dist_dry = .m if ancpast_nurs != 1
replace ancpast_nurs_dist_wet = .m if ancpast_nurs != 1
tab1 ancpast_nurs_dist_dry ancpast_nurs_dist_wet , m
// ancpast_nurs_visit ancpast_nurs_1tri_times ancpast_nurs_2tri_times ancpast_nurs_3tri_times
destring ancpast_nurs_visit ancpast_nurs_1tri_times ancpast_nurs_2tri_times ancpast_nurs_3tri_times, replace
replace ancpast_nurs_visit = .m if ancpast_adopt == 1
replace ancpast_nurs_visit = .m if ancpast_nurs != 1
replace ancpast_nurs_visit = .n if ancpast_nurs_visit == 444
replace ancpast_nurs_1tri_times = .m if mi(ancpast_nurs_visit)
replace ancpast_nurs_2tri_times = .m if mi(ancpast_nurs_visit)
replace ancpast_nurs_3tri_times = .m if mi(ancpast_nurs_visit)
replace ancpast_nurs_1tri_times = .n if ancpast_nurs_1tri_times == 444
replace ancpast_nurs_2tri_times = .n if ancpast_nurs_2tri_times == 444
replace ancpast_nurs_3tri_times = .n if ancpast_nurs_3tri_times == 444
tab1 ancpast_nurs_visit ancpast_nurs_1tri_times ancpast_nurs_2tri_times ancpast_nurs_3tri_times, m
// ancpast_ha_where ancpast_ha_where_oth ancpast_ha_dist_dry ancpast_ha_dist_wet ancpast_ha_visit ancpast_ha_1tri_times ancpast_ha_2tri_times ancpast_ha_3tri_times
destring ancpast_ha_where, replace
replace ancpast_ha_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_ha_where_`x' = (ancpast_ha_where == `x')
replace ancpast_ha_where_`x' = .m if mi(ancpast_ha_where)
tab ancpast_ha_where_`x', m
}
rename ancpast_ha_where_1 ancpast_ha_home
rename ancpast_ha_where_2 ancpast_ha_hosp
rename ancpast_ha_where_3 ancpast_ha_clinic
rename ancpast_ha_where_4 ancpast_ha_rhc
rename ancpast_ha_where_5 ancpast_ha_vill
rename ancpast_ha_where_6 ancpast_ha_eho
rename ancpast_ha_where_888 ancpast_ha_othplc
// ancpast_ha_where_oth
// ancpast_ha_dist_dry ancpast_ha_dist_wet
destring ancpast_ha_dist_dry ancpast_ha_dist_wet , replace
replace ancpast_ha_dist_dry = .m if ancpast_adopt == 1
replace ancpast_ha_dist_wet = .m if ancpast_adopt == 1
replace ancpast_ha_dist_dry = .m if ancpast_ha != 1
replace ancpast_ha_dist_wet = .m if ancpast_ha != 1
tab1 ancpast_ha_dist_dry ancpast_ha_dist_wet , m
// ancpast_ha_visit ancpast_ha_1tri_times ancpast_ha_2tri_times ancpast_ha_3tri_times
destring ancpast_ha_visit ancpast_ha_1tri_times ancpast_ha_2tri_times ancpast_ha_3tri_times, replace
replace ancpast_ha_visit = .m if ancpast_adopt == 1
replace ancpast_ha_visit = .m if ancpast_ha != 1
replace ancpast_ha_visit = .n if ancpast_ha_visit == 444
replace ancpast_ha_1tri_times = .m if mi(ancpast_ha_visit)
replace ancpast_ha_2tri_times = .m if mi(ancpast_ha_visit)
replace ancpast_ha_3tri_times = .m if mi(ancpast_ha_visit)
replace ancpast_ha_1tri_times = .n if ancpast_ha_1tri_times == 444
replace ancpast_ha_2tri_times = .n if ancpast_ha_2tri_times == 444
replace ancpast_ha_3tri_times = .n if ancpast_ha_3tri_times == 444
tab1 ancpast_ha_visit ancpast_ha_1tri_times ancpast_ha_2tri_times ancpast_ha_3tri_times, m
// ancpast_pdoc_where ancpast_pdoc_where_oth ancpast_pdoc_dist_dry ancpast_pdoc_dist_wet ancpast_pdoc_visit ancpast_pdoc_1tri_times ancpast_pdoc_2tri_times ancpast_pdoc_3tri_times
destring ancpast_pdoc_where, replace
replace ancpast_pdoc_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_pdoc_where_`x' = (ancpast_pdoc_where == `x')
replace ancpast_pdoc_where_`x' = .m if mi(ancpast_pdoc_where)
tab ancpast_pdoc_where_`x', m
}
rename ancpast_pdoc_where_1 ancpast_pdoc_home
rename ancpast_pdoc_where_2 ancpast_pdoc_hosp
rename ancpast_pdoc_where_3 ancpast_pdoc_clinic
rename ancpast_pdoc_where_4 ancpast_pdoc_rhc
rename ancpast_pdoc_where_5 ancpast_pdoc_vill
rename ancpast_pdoc_where_6 ancpast_pdoc_eho
rename ancpast_pdoc_where_888 ancpast_pdoc_othplc
// ancpast_pdoc_where_oth
// ancpast_pdoc_dist_dry ancpast_pdoc_dist_wet
destring ancpast_pdoc_dist_dry ancpast_pdoc_dist_wet , replace
replace ancpast_pdoc_dist_dry = .m if ancpast_adopt == 1
replace ancpast_pdoc_dist_wet = .m if ancpast_adopt == 1
replace ancpast_pdoc_dist_dry = .m if ancpast_pdoc != 1
replace ancpast_pdoc_dist_wet = .m if ancpast_pdoc != 1
tab1 ancpast_pdoc_dist_dry ancpast_pdoc_dist_wet , m
// ancpast_pdoc_visit ancpast_pdoc_1tri_times ancpast_pdoc_2tri_times ancpast_pdoc_3tri_times
destring ancpast_pdoc_visit ancpast_pdoc_1tri_times ancpast_pdoc_2tri_times ancpast_pdoc_3tri_times, replace
replace ancpast_pdoc_visit = .m if ancpast_adopt == 1
replace ancpast_pdoc_visit = .m if ancpast_pdoc != 1
replace ancpast_pdoc_visit = .n if ancpast_pdoc_visit == 444
replace ancpast_pdoc_1tri_times = .m if mi(ancpast_pdoc_visit)
replace ancpast_pdoc_2tri_times = .m if mi(ancpast_pdoc_visit)
replace ancpast_pdoc_3tri_times = .m if mi(ancpast_pdoc_visit)
replace ancpast_pdoc_1tri_times = .n if ancpast_pdoc_1tri_times == 444
replace ancpast_pdoc_2tri_times = .n if ancpast_pdoc_2tri_times == 444
replace ancpast_pdoc_3tri_times = .n if ancpast_pdoc_3tri_times == 444
tab1 ancpast_pdoc_visit ancpast_pdoc_1tri_times ancpast_pdoc_2tri_times ancpast_pdoc_3tri_times, m
// ancpast_lhv_where ancpast_lhv_where_oth ancpast_lhv_dist_dry ancpast_lhv_dist_wet ancpast_lhv_visit ancpast_lhv_1tri_times ancpast_lhv_2tri_times ancpast_lhv_3tri_times
destring ancpast_lhv_where, replace
replace ancpast_lhv_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_lhv_where_`x' = (ancpast_lhv_where == `x')
replace ancpast_lhv_where_`x' = .m if mi(ancpast_lhv_where)
tab ancpast_lhv_where_`x', m
}
rename ancpast_lhv_where_1 ancpast_lhv_home
rename ancpast_lhv_where_2 ancpast_lhv_hosp
rename ancpast_lhv_where_3 ancpast_lhv_clinic
rename ancpast_lhv_where_4 ancpast_lhv_rhc
rename ancpast_lhv_where_5 ancpast_lhv_vill
rename ancpast_lhv_where_6 ancpast_lhv_eho
rename ancpast_lhv_where_888 ancpast_lhv_othplc
// ancpast_lhv_where_oth
// ancpast_lhv_dist_dry ancpast_lhv_dist_wet
destring ancpast_lhv_dist_dry ancpast_lhv_dist_wet , replace
replace ancpast_lhv_dist_dry = .m if ancpast_adopt == 1
replace ancpast_lhv_dist_wet = .m if ancpast_adopt == 1
replace ancpast_lhv_dist_dry = .m if ancpast_lhv != 1
replace ancpast_lhv_dist_wet = .m if ancpast_lhv != 1
tab1 ancpast_lhv_dist_dry ancpast_lhv_dist_wet , m
// ancpast_lhv_visit ancpast_lhv_1tri_times ancpast_lhv_2tri_times ancpast_lhv_3tri_times
destring ancpast_lhv_visit ancpast_lhv_1tri_times ancpast_lhv_2tri_times ancpast_lhv_3tri_times, replace
replace ancpast_lhv_visit = .m if ancpast_adopt == 1
replace ancpast_lhv_visit = .m if ancpast_lhv != 1
replace ancpast_lhv_visit = .n if ancpast_lhv_visit == 444
replace ancpast_lhv_1tri_times = .m if mi(ancpast_lhv_visit)
replace ancpast_lhv_2tri_times = .m if mi(ancpast_lhv_visit)
replace ancpast_lhv_3tri_times = .m if mi(ancpast_lhv_visit)
replace ancpast_lhv_1tri_times = .n if ancpast_lhv_1tri_times == 444
replace ancpast_lhv_2tri_times = .n if ancpast_lhv_2tri_times == 444
replace ancpast_lhv_3tri_times = .n if ancpast_lhv_3tri_times == 444
tab1 ancpast_lhv_visit ancpast_lhv_1tri_times ancpast_lhv_2tri_times ancpast_lhv_3tri_times, m
// ancpast_mw_where ancpast_mw_where_oth ancpast_mw_dist_dry ancpast_mw_dist_wet ancpast_mw_visit ancpast_mw_1tri_times ancpast_mw_2tri_times ancpast_mw_3tri_times
destring ancpast_mw_where, replace
replace ancpast_mw_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_mw_where_`x' = (ancpast_mw_where == `x')
replace ancpast_mw_where_`x' = .m if mi(ancpast_mw_where)
tab ancpast_mw_where_`x', m
}
rename ancpast_mw_where_1 ancpast_mw_home
rename ancpast_mw_where_2 ancpast_mw_hosp
rename ancpast_mw_where_3 ancpast_mw_clinic
rename ancpast_mw_where_4 ancpast_mw_rhc
rename ancpast_mw_where_5 ancpast_mw_vill
rename ancpast_mw_where_6 ancpast_mw_eho
rename ancpast_mw_where_888 ancpast_mw_othplc
// ancpast_mw_where_oth
// ancpast_mw_dist_dry ancpast_mw_dist_wet
destring ancpast_mw_dist_dry ancpast_mw_dist_wet , replace
replace ancpast_mw_dist_dry = .m if ancpast_adopt == 1
replace ancpast_mw_dist_wet = .m if ancpast_adopt == 1
replace ancpast_mw_dist_dry = .m if ancpast_mw != 1
replace ancpast_mw_dist_wet = .m if ancpast_mw != 1
tab1 ancpast_mw_dist_dry ancpast_mw_dist_wet , m
// ancpast_mw_visit ancpast_mw_1tri_times ancpast_mw_2tri_times ancpast_mw_3tri_times
destring ancpast_mw_visit ancpast_mw_1tri_times ancpast_mw_2tri_times ancpast_mw_3tri_times, replace
replace ancpast_mw_visit = .m if ancpast_adopt == 1
replace ancpast_mw_visit = .m if ancpast_mw != 1
replace ancpast_mw_visit = .n if ancpast_mw_visit == 444
replace ancpast_mw_1tri_times = .m if mi(ancpast_mw_visit)
replace ancpast_mw_2tri_times = .m if mi(ancpast_mw_visit)
replace ancpast_mw_3tri_times = .m if mi(ancpast_mw_visit)
replace ancpast_mw_1tri_times = .n if ancpast_mw_1tri_times == 444
replace ancpast_mw_2tri_times = .n if ancpast_mw_2tri_times == 444
replace ancpast_mw_3tri_times = .n if ancpast_mw_3tri_times == 444
tab1 ancpast_mw_visit ancpast_mw_1tri_times ancpast_mw_2tri_times ancpast_mw_3tri_times, m
// ancpast_amw_where ancpast_amw_where_oth ancpast_amw_dist_dry ancpast_amw_dist_wet ancpast_amw_visit ancpast_amw_1tri_times ancpast_amw_2tri_times ancpast_amw_3tri_times
destring ancpast_amw_where, replace
replace ancpast_amw_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_amw_where_`x' = (ancpast_amw_where == `x')
replace ancpast_amw_where_`x' = .m if mi(ancpast_amw_where)
tab ancpast_amw_where_`x', m
}
rename ancpast_amw_where_1 ancpast_amw_home
rename ancpast_amw_where_2 ancpast_amw_hosp
rename ancpast_amw_where_3 ancpast_amw_clinic
rename ancpast_amw_where_4 ancpast_amw_rhc
rename ancpast_amw_where_5 ancpast_amw_vill
rename ancpast_amw_where_6 ancpast_amw_eho
rename ancpast_amw_where_888 ancpast_amw_othplc
// ancpast_amw_where_oth
// ancpast_amw_dist_dry ancpast_amw_dist_wet
destring ancpast_amw_dist_dry ancpast_amw_dist_wet , replace
replace ancpast_amw_dist_dry = .m if ancpast_adopt == 1
replace ancpast_amw_dist_wet = .m if ancpast_adopt == 1
replace ancpast_amw_dist_dry = .m if ancpast_amw != 1
replace ancpast_amw_dist_wet = .m if ancpast_amw != 1
tab1 ancpast_amw_dist_dry ancpast_amw_dist_wet , m
// ancpast_amw_visit ancpast_amw_1tri_times ancpast_amw_2tri_times ancpast_amw_3tri_times
destring ancpast_amw_visit ancpast_amw_1tri_times ancpast_amw_2tri_times ancpast_amw_3tri_times, replace
replace ancpast_amw_visit = .m if ancpast_adopt == 1
replace ancpast_amw_visit = .m if ancpast_amw != 1
replace ancpast_amw_visit = .n if ancpast_amw_visit == 444
replace ancpast_amw_1tri_times = .m if mi(ancpast_amw_visit)
replace ancpast_amw_2tri_times = .m if mi(ancpast_amw_visit)
replace ancpast_amw_3tri_times = .m if mi(ancpast_amw_visit)
replace ancpast_amw_1tri_times = .n if ancpast_amw_1tri_times == 444
replace ancpast_amw_2tri_times = .n if ancpast_amw_2tri_times == 444
replace ancpast_amw_3tri_times = .n if ancpast_amw_3tri_times == 444
tab1 ancpast_amw_visit ancpast_amw_1tri_times ancpast_amw_2tri_times ancpast_amw_3tri_times, m
// ancpast_tba_where ancpast_tba_where_oth ancpast_tba_dist_dry ancpast_tba_dist_wet ancpast_tba_visit ancpast_tba_1tri_times ancpast_tba_2tri_times ancpast_tba_3tri_times
destring ancpast_tba_where, replace
replace ancpast_tba_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_tba_where_`x' = (ancpast_tba_where == `x')
replace ancpast_tba_where_`x' = .m if mi(ancpast_tba_where)
tab ancpast_tba_where_`x', m
}
rename ancpast_tba_where_1 ancpast_tba_home
rename ancpast_tba_where_2 ancpast_tba_hosp
rename ancpast_tba_where_3 ancpast_tba_clinic
rename ancpast_tba_where_4 ancpast_tba_rhc
rename ancpast_tba_where_5 ancpast_tba_vill
rename ancpast_tba_where_6 ancpast_tba_eho
rename ancpast_tba_where_888 ancpast_tba_othplc
// ancpast_tba_where_oth
// ancpast_tba_dist_dry ancpast_tba_dist_wet
destring ancpast_tba_dist_dry ancpast_tba_dist_wet , replace
replace ancpast_tba_dist_dry = .m if ancpast_adopt == 1
replace ancpast_tba_dist_wet = .m if ancpast_adopt == 1
replace ancpast_tba_dist_dry = .m if ancpast_tba != 1
replace ancpast_tba_dist_wet = .m if ancpast_tba != 1
tab1 ancpast_tba_dist_dry ancpast_tba_dist_wet , m
// ancpast_tba_visit ancpast_tba_1tri_times ancpast_tba_2tri_times ancpast_tba_3tri_times
destring ancpast_tba_visit ancpast_tba_1tri_times ancpast_tba_2tri_times ancpast_tba_3tri_times, replace
replace ancpast_tba_visit = .m if ancpast_adopt == 1
replace ancpast_tba_visit = .m if ancpast_tba != 1
replace ancpast_tba_visit = .n if ancpast_tba_visit == 444
replace ancpast_tba_1tri_times = .m if mi(ancpast_tba_visit)
replace ancpast_tba_2tri_times = .m if mi(ancpast_tba_visit)
replace ancpast_tba_3tri_times = .m if mi(ancpast_tba_visit)
replace ancpast_tba_1tri_times = .n if ancpast_tba_1tri_times == 444
replace ancpast_tba_2tri_times = .n if ancpast_tba_2tri_times == 444
replace ancpast_tba_3tri_times = .n if ancpast_tba_3tri_times == 444
tab1 ancpast_tba_visit ancpast_tba_1tri_times ancpast_tba_2tri_times ancpast_tba_3tri_times, m
// ancpast_chw_where ancpast_chw_where_oth ancpast_chw_dist_dry ancpast_chw_dist_wet ancpast_chw_visit ancpast_chw_1tri_times ancpast_chw_2tri_times ancpast_chw_3tri_times
destring ancpast_chw_where, replace
replace ancpast_chw_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_chw_where_`x' = (ancpast_chw_where == `x')
replace ancpast_chw_where_`x' = .m if mi(ancpast_chw_where)
tab ancpast_chw_where_`x', m
}
rename ancpast_chw_where_1 ancpast_chw_home
rename ancpast_chw_where_2 ancpast_chw_hosp
rename ancpast_chw_where_3 ancpast_chw_clinic
rename ancpast_chw_where_4 ancpast_chw_rhc
rename ancpast_chw_where_5 ancpast_chw_vill
rename ancpast_chw_where_6 ancpast_chw_eho
rename ancpast_chw_where_888 ancpast_chw_othplc
// ancpast_chw_where_oth
// ancpast_chw_dist_dry ancpast_chw_dist_wet
destring ancpast_chw_dist_dry ancpast_chw_dist_wet , replace
replace ancpast_chw_dist_dry = .m if ancpast_adopt == 1
replace ancpast_chw_dist_wet = .m if ancpast_adopt == 1
replace ancpast_chw_dist_dry = .m if ancpast_chw != 1
replace ancpast_chw_dist_wet = .m if ancpast_chw != 1
tab1 ancpast_chw_dist_dry ancpast_chw_dist_wet , m
// ancpast_chw_visit ancpast_chw_1tri_times ancpast_chw_2tri_times ancpast_chw_3tri_times
destring ancpast_chw_visit ancpast_chw_1tri_times ancpast_chw_2tri_times ancpast_chw_3tri_times, replace
replace ancpast_chw_visit = .m if ancpast_adopt == 1
replace ancpast_chw_visit = .m if ancpast_chw != 1
replace ancpast_chw_visit = .n if ancpast_chw_visit == 444
replace ancpast_chw_1tri_times = .m if mi(ancpast_chw_visit)
replace ancpast_chw_2tri_times = .m if mi(ancpast_chw_visit)
replace ancpast_chw_3tri_times = .m if mi(ancpast_chw_visit)
replace ancpast_chw_1tri_times = .n if ancpast_chw_1tri_times == 444
replace ancpast_chw_2tri_times = .n if ancpast_chw_2tri_times == 444
replace ancpast_chw_3tri_times = .n if ancpast_chw_3tri_times == 444
tab1 ancpast_chw_visit ancpast_chw_1tri_times ancpast_chw_2tri_times ancpast_chw_3tri_times, m
// ancpast_ehw_where ancpast_ehw_where_oth ancpast_ehw_dist_dry ancpast_ehw_dist_wet ancpast_ehw_visit ancpast_ehw_1tri_times ancpast_ehw_2tri_times ancpast_ehw_3tri_times
destring ancpast_ehw_where, replace
replace ancpast_ehw_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_ehw_where_`x' = (ancpast_ehw_where == `x')
replace ancpast_ehw_where_`x' = .m if mi(ancpast_ehw_where)
tab ancpast_ehw_where_`x', m
}
rename ancpast_ehw_where_1 ancpast_ehw_home
rename ancpast_ehw_where_2 ancpast_ehw_hosp
rename ancpast_ehw_where_3 ancpast_ehw_clinic
rename ancpast_ehw_where_4 ancpast_ehw_rhc
rename ancpast_ehw_where_5 ancpast_ehw_vill
rename ancpast_ehw_where_6 ancpast_ehw_eho
rename ancpast_ehw_where_888 ancpast_ehw_othplc
// ancpast_ehw_where_oth
// ancpast_ehw_dist_dry ancpast_ehw_dist_wet
destring ancpast_ehw_dist_dry ancpast_ehw_dist_wet , replace
replace ancpast_ehw_dist_dry = .m if ancpast_adopt == 1
replace ancpast_ehw_dist_wet = .m if ancpast_adopt == 1
replace ancpast_ehw_dist_dry = .m if ancpast_ehw != 1
replace ancpast_ehw_dist_wet = .m if ancpast_ehw != 1
tab1 ancpast_ehw_dist_dry ancpast_ehw_dist_wet , m
// ancpast_ehw_visit ancpast_ehw_1tri_times ancpast_ehw_2tri_times ancpast_ehw_3tri_times
destring ancpast_ehw_visit ancpast_ehw_1tri_times ancpast_ehw_2tri_times ancpast_ehw_3tri_times, replace
replace ancpast_ehw_visit = .m if ancpast_adopt == 1
replace ancpast_ehw_visit = .m if ancpast_ehw != 1
replace ancpast_ehw_visit = .n if ancpast_ehw_visit == 444
replace ancpast_ehw_1tri_times = .m if mi(ancpast_ehw_visit)
replace ancpast_ehw_2tri_times = .m if mi(ancpast_ehw_visit)
replace ancpast_ehw_3tri_times = .m if mi(ancpast_ehw_visit)
replace ancpast_ehw_1tri_times = .n if ancpast_ehw_1tri_times == 444
replace ancpast_ehw_2tri_times = .n if ancpast_ehw_2tri_times == 444
replace ancpast_ehw_3tri_times = .n if ancpast_ehw_3tri_times == 444
tab1 ancpast_ehw_visit ancpast_ehw_1tri_times ancpast_ehw_2tri_times ancpast_ehw_3tri_times, m
// ancpast_oth_where ancpast_oth_where_oth ancpast_oth_dist_dry ancpast_oth_dist_wet ancpast_oth_visit ancpast_oth_1tri_times ancpast_oth_2tri_times ancpast_oth_3tri_times
destring ancpast_oth_where, replace
replace ancpast_oth_where = .m if ancpast_adopt == 1
local num 1 2 3 4 5 6 888
foreach x in `num' {
gen ancpast_oth_where_`x' = (ancpast_oth_where == `x')
replace ancpast_oth_where_`x' = .m if mi(ancpast_oth_where)
tab ancpast_oth_where_`x', m
}
rename ancpast_oth_where_1 ancpast_oth_home
rename ancpast_oth_where_2 ancpast_oth_hosp
rename ancpast_oth_where_3 ancpast_oth_clinic
rename ancpast_oth_where_4 ancpast_oth_rhc
rename ancpast_oth_where_5 ancpast_oth_vill
rename ancpast_oth_where_6 ancpast_oth_eho
rename ancpast_oth_where_888 ancpast_oth_othplc
// ancpast_oth_where_oth
// ancpast_oth_dist_dry ancpast_oth_dist_wet
destring ancpast_oth_dist_dry ancpast_oth_dist_wet , replace
replace ancpast_oth_dist_dry = .m if ancpast_adopt == 1
replace ancpast_oth_dist_wet = .m if ancpast_adopt == 1
replace ancpast_oth_dist_dry = .m if ancpast_oth != 1
replace ancpast_oth_dist_wet = .m if ancpast_oth != 1
tab1 ancpast_oth_dist_dry ancpast_oth_dist_wet , m
// ancpast_oth_visit ancpast_oth_1tri_times ancpast_oth_2tri_times ancpast_oth_3tri_times
destring ancpast_oth_visit ancpast_oth_1tri_times ancpast_oth_2tri_times ancpast_oth_3tri_times, replace
replace ancpast_oth_visit = .m if ancpast_adopt == 1
replace ancpast_oth_visit = .m if ancpast_oth != 1
replace ancpast_oth_visit = .n if ancpast_oth_visit == 444
replace ancpast_oth_1tri_times = .m if mi(ancpast_oth_visit)
replace ancpast_oth_2tri_times = .m if mi(ancpast_oth_visit)
replace ancpast_oth_3tri_times = .m if mi(ancpast_oth_visit)
replace ancpast_oth_1tri_times = .n if ancpast_oth_1tri_times == 444
replace ancpast_oth_2tri_times = .n if ancpast_oth_2tri_times == 444
replace ancpast_oth_3tri_times = .n if ancpast_oth_3tri_times == 444
tab1 ancpast_oth_visit ancpast_oth_1tri_times ancpast_oth_2tri_times ancpast_oth_3tri_times, m
// ancpast_cost
destring ancpast_cost, replace
replace ancpast_cost = .d if ancpast_cost == 999
replace ancpast_cost = .m if ancpast_yn != 1
tab ancpast_cost, m
// ancpast_amount
destring ancpast_amount, replace
replace ancpast_amount = .d if ancpast_amount == 999
replace ancpast_amount = .r if ancpast_amount == 666
replace ancpast_amount = .n if ancpast_amount == 444
replace ancpast_amount = .m if ancpast_cost != 1
tab ancpast_amount, m
// ancpast_costitem
local items ancpast_costitem1 ancpast_costitem2 ancpast_costitem3 ancpast_costitem4 ancpast_costitem5 ancpast_costitem6 ancpast_costitem888
foreach var in `items' {
destring `var', replace
replace `var' = .m if mi(ancpast_amount)
tab `var', m
}
rename ancpast_costitem1 ancpast_cost_ta
rename ancpast_costitem2 ancpast_cost_reg
rename ancpast_costitem3 ancpast_cost_drug
rename ancpast_costitem4 ancpast_cost_lab
rename ancpast_costitem5 ancpast_cost_consult
rename ancpast_costitem6 ancpast_cost_gift
rename ancpast_costitem888 ancpast_cost_oth
// ancpast_costitem_oth
// ancpast_borrow
destring ancpast_borrow, replace
replace ancpast_borrow = .m if ancpast_cost != 1
tab ancpast_borrow, m
/*
// ancpast_mchbook
destring ancpast_mchbook, replace
replace ancpast_mchbook = .m if ancpast_yn != 1
tab ancpast_mchbook, m
// ancpast_conselling
destring ancpast_conselling, replace
replace ancpast_conselling = .m if ancpast_yn != 1
tab ancpast_conselling, m
*/
// ancpast_noreason
destring ancpast_noreason, replace
replace ancpast_noreason = .d if ancpast_noreason == 999
replace ancpast_noreason = .m if ancpast_yn != 0
tab ancpast_noreason, m
local val 1 2 3 4 5 6 7 888
foreach x in `val' {
gen ancpast_noreason_`x' = (ancpast_noreason == `x')
replace ancpast_noreason_`x' = .m if mi(ancpast_noreason)
order ancpast_noreason_`x', before(ancpast_restrict)
tab ancpast_noreason_`x', m
}
rename ancpast_noreason_1 ancpast_no_important
rename ancpast_noreason_2 ancpast_no_distance
rename ancpast_noreason_3 ancpast_no_restrict
rename ancpast_noreason_4 ancpast_no_accompany
rename ancpast_noreason_5 ancpast_no_hf
rename ancpast_noreason_6 ancpast_no_staff
rename ancpast_noreason_7 ancpast_no_finance
rename ancpast_noreason_888 ancpast_no_oth
// ancpast_noreason_oth
// ancpast_restrict
destring ancpast_restrict, replace
replace ancpast_restrict = .m if ancpast_adopt == 1
tab ancpast_restrict, m
// ancpast_restrict_item
local items ancpast_restrict_item1 ancpast_restrict_item2 ancpast_restrict_item3 ancpast_restrict_item4 ancpast_restrict_item5 ancpast_restrict_item6 ancpast_restrict_item888
foreach var in `items' {
destring `var', replace
replace `var' = .m if ancpast_restrict != 1
tab `var', m
}
rename ancpast_restrict_item1 ancpast_restrict_veg
rename ancpast_restrict_item2 ancpast_restrict_fruit
rename ancpast_restrict_item3 ancpast_restrict_grain
rename ancpast_restrict_item4 ancpast_restrict_meat
rename ancpast_restrict_item5 ancpast_restrict_fish
rename ancpast_restrict_item6 ancpast_restrict_diary
rename ancpast_restrict_item888 ancpast_restrict_oth
// ancpast_restrict_item_oth
// ancpast_restrict_why
destring ancpast_restrict_why, replace
replace ancpast_restrict_why = .m if ancpast_restrict != 1
tab ancpast_restrict_why, m
local val 1 2 888
foreach x in `val' {
gen ancpast_restrict_why_`x' = (ancpast_restrict_why == `x')
replace ancpast_restrict_why_`x' = .m if ancpast_restrict != 1
order ancpast_restrict_why_`x', before(ancpast_bone)
tab ancpast_restrict_why_`x', m
}
rename ancpast_restrict_why_1 ancpast_restrict_adult
rename ancpast_restrict_why_2 ancpast_restrict_tradit
rename ancpast_restrict_why_888 ancpast_restrict_whyoth
// ancpast_restrict_why_oth
// ancpast_bone
destring ancpast_bone, replace
replace ancpast_bone = .d if ancpast_bone == 999
replace ancpast_bone = .m if ancpast_adopt == 1
tab ancpast_bone, m
// ancpast_rion
destring ancpast_rion, replace
replace ancpast_rion = .d if ancpast_rion == 999
replace ancpast_rion = .m if ancpast_adopt == 1
tab ancpast_rion, m
// ancpast_iron_freq
destring ancpast_iron_freq, replace
replace ancpast_rion = .d if ancpast_rion == 999
replace ancpast_iron_freq = .m if ancpast_rion != 1
tab ancpast_iron_freq, m
local val 0 1 2 3
foreach x in `val' {
gen ancpast_iron_freq_`x' = (ancpast_iron_freq == `x')
replace ancpast_iron_freq_`x' = .m if ancpast_rion != 1
order ancpast_iron_freq_`x', before(ancpast_iron_freq_lab)
tab ancpast_iron_freq_`x', m
}
rename ancpast_iron_freq_0 ancpast_iron_freq_no
rename ancpast_iron_freq_1 ancpast_iron_freq_day
rename ancpast_iron_freq_2 ancpast_iron_freq_wk
rename ancpast_iron_freq_3 ancpast_iron_freq_month
// ancpast_iron_freq_lab
// ancpast_iron_count
destring ancpast_iron_count, replace
replace ancpast_iron_count = .n if ancpast_iron_count == 444 | ancpast_iron_count == 0
replace ancpast_iron_count = .m if mi(ancpast_iron_freq) | ancpast_iron_freq == 0
tab ancpast_iron_count, m
// ancpast_rion_length
destring ancpast_rion_length, replace
replace ancpast_rion_length = .m if mi(ancpast_iron_count)
tab ancpast_rion_length, m
gen ancpast_rion_less_month = (ancpast_rion_length == 1)
replace ancpast_rion_less_month = .m if mi(ancpast_rion_length)
order ancpast_rion_less_month, after(ancpast_rion_length)
tab ancpast_rion_less_month, m
// ancpast_rion_length_oth
destring ancpast_rion_length_oth, replace
replace ancpast_rion_length_oth = 0.5 if ancpast_rion_length == 1 // assumed only half of a month
replace ancpast_rion_length_oth = .d if ancpast_rion_length_oth == 999
replace ancpast_rion_length_oth = .n if ancpast_rion_length_oth == 444
replace ancpast_rion_length_oth = .m if mi(ancpast_iron_count)
tab ancpast_rion_length_oth, m
rename ancpast_rion_length_oth ancpast_rion_lengthnum
// ancpast_iron_cost
destring ancpast_iron_cost, replace
replace ancpast_iron_cost = .m if ancpast_rion != 1
tab ancpast_iron_cost, m
// ancpast_iron_amount
destring ancpast_iron_amount, replace
replace ancpast_iron_amount = .d if ancpast_iron_amount == 999
replace ancpast_iron_amount = .n if ancpast_iron_amount == 444 | ancpast_iron_amount == 5
replace ancpast_iron_amount = .m if ancpast_iron_cost != 1
tab ancpast_iron_amount, m
// ancpast_iron_source
local iron ancpast_iron_source1 ancpast_iron_source2 ancpast_iron_source3 ancpast_iron_source4 ancpast_iron_source5 ancpast_iron_source888
foreach var in `iron' {
destring `var', replace
replace `var' = .m if ancpast_rion != 1
tab `var', m
}
rename ancpast_iron_source1 ancpast_iron_hosp
rename ancpast_iron_source2 ancpast_iron_eho
rename ancpast_iron_source3 ancpast_iron_pdoc
rename ancpast_iron_source4 ancpast_iron_rhc
rename ancpast_iron_source5 ancpast_iron_vill
rename ancpast_iron_source888 ancpast_iron_oth
// ancpast_iron_source_oth
/*
// ancpast_test_yesno
local test ancpast_test_yesno0 ancpast_test_yesno1 ancpast_test_yesno2 ancpast_test_yesno3 ancpast_test_yesno4 ancpast_test_yesno888 ancpast_test_yesno999
foreach var in `test' {
destring `var', replace
replace `var' = .m if ancpast_adopt == 1
tab `var', m
}
gen ancpast_test_yes = (ancpast_test_yesno != "0" & ancpast_test_yesno != "999")
replace ancpast_test_yes = .d if ancpast_test_yesno == "999"
replace ancpast_test_yes = .m if mi(ancpast_test_yesno)
tab ancpast_test_yes, m
order ancpast_test_yes, after(ancpast_test_yesno)
rename ancpast_test_yesno0 ancpast_test_no
rename ancpast_test_yesno1 ancpast_test_hepb
rename ancpast_test_yesno2 ancpast_test_hepc
rename ancpast_test_yesno3 ancpast_test_hiv
rename ancpast_test_yesno4 ancpast_test_std
rename ancpast_test_yesno888 ancpast_test_oth
rename ancpast_test_yesno999 ancpast_test_dk
// ancpast_test_yesno_oth
// ancpast_test_where
local where ancpast_test_where1 ancpast_test_where2 ancpast_test_where3 ancpast_test_where4 ancpast_test_where5 ancpast_test_where888
foreach var in `where' {
destring `var', replace
replace `var' = .m if mi(ancpast_test_where)
tab `var', m
}
rename ancpast_test_where1 ancpast_test_hosp
rename ancpast_test_where2 ancpast_test_eho
rename ancpast_test_where3 ancpast_test_pdoc
rename ancpast_test_where4 ancpast_test_rhc
rename ancpast_test_where5 ancpast_test_vill
rename ancpast_test_where888 ancpast_test_plcoth
// ancpast_test_cost
destring ancpast_test_cost, replace
replace ancpast_test_cost = .d if ancpast_test_cost == 999
replace ancpast_test_cost = .n if ancpast_test_cost == 444 | ancpast_test_cost < 500
replace ancpast_test_cost = .m if ancpast_test_cost == .
tab ancpast_test_cost, m
// ancpast_test_where_oth
*/
*** reporting variable generation ***
* anc with trained health personnel
gen ancpast_trained = 0
replace ancpast_trained = .m if ancpast_yn != 1
local trained ancpast_spelist ancpast_doc ancpast_nurs ancpast_ha ancpast_pdoc ///
ancpast_lhv ancpast_mw ancpast_ehw
foreach var in `trained' {
replace ancpast_trained = 1 if `var' == 1
}
tab ancpast_trained, m
* anc visits freq with trained health personnel
egen ancpast_trained_freq = rowtotal(ancpast_spelist_visit ancpast_doc_visit ancpast_nurs_visit ///
ancpast_ha_visit ancpast_pdoc_visit ancpast_lhv_visit ancpast_mw_visit ///
ancpast_ehw_visit)
replace ancpast_trained_freq = .m if mi(ancpast_yn)
tab ancpast_trained_freq, m
* Winsorized
winsor2 ancpast_trained_freq, replace cuts(1 75)
* anc visits freq detail with trained health personnel
forvalue x = 1/4 {
gen ancpast_trained_freq`x' = (ancpast_trained_freq >= `x')
replace ancpast_trained_freq`x' = .m if mi(ancpast_trained_freq)
tab ancpast_trained_freq`x', m
}
order ancpast_trained ancpast_trained_freq ancpast_trained_freq1 ancpast_trained_freq2 ///
ancpast_trained_freq3 ancpast_trained_freq4, before(ancpast_cost)
* iron calculation
// ancpast_bone ancpast_rion ancpast_iron_freq ancpast_iron_freq_no
// ancpast_iron_freq_day ancpast_iron_freq_wk ancpast_iron_freq_month
// ancpast_iron_count ancpast_rion_less_month ancpast_rion_lengthnum ancpast_iron_cost ancpast_iron_amount
gen ancpast_iron_consum = .m
replace ancpast_iron_consum = 0 if ancpast_rion == 0
replace ancpast_iron_consum = round(ancpast_iron_count * 30 * ancpast_rion_lengthnum,0.1) if ancpast_iron_freq_day == 1
replace ancpast_iron_consum = round(ancpast_iron_count * 4 * ancpast_rion_lengthnum,0.1) if ancpast_iron_freq_wk == 1
replace ancpast_iron_consum = round(ancpast_iron_count * ancpast_rion_lengthnum,0.1) if ancpast_iron_freq_month == 1
replace ancpast_iron_consum = .m if mi(ancpast_iron_count) & ancpast_rion != 0
replace ancpast_iron_consum = .m if mi(ancpast_rion_lengthnum) & ancpast_rion != 0
tab ancpast_iron_consum, m
* Winsorized
winsor2 ancpast_iron_consum, replace cuts(1 95)
order ancpast_iron_consum , after(ancpast_rion_lengthnum)
** reporting variables **
lab var ancpast_yn "Received ANC"
lab var ancpast_spelist "ANC - Specialist"
lab var ancpast_doc "ANC - Doctor"
lab var ancpast_nurs "ANC - Nurse"
lab var ancpast_ha "ANC - Health assistant"
lab var ancpast_pdoc "ANC - Private doctor"
lab var ancpast_lhv "ANC - LHV"
lab var ancpast_mw "ANC - Midwife"
lab var ancpast_amw "ANC - AMW"
lab var ancpast_tba "ANC - TBA"
lab var ancpast_chw "ANC - Community Health Worker"
lab var ancpast_ehw "ANC - Ethnic health worker"
lab var ancpast_oth "ANC - other"
lab var ancpast_spelist_home "Specialist at home"
lab var ancpast_spelist_hosp "Specialist at Government hospital"
lab var ancpast_spelist_clinic "Specialist at Private doctor/clinic"
lab var ancpast_spelist_rhc "Specialist at SRHC-RHC"
lab var ancpast_spelist_vill "Specialist at Routine ANC place within village/ward"
lab var ancpast_spelist_eho "Specialist at EHO clinic"
lab var ancpast_spelist_othplc "Specialist at other places"
lab var ancpast_spelist_visit "Specialist - ANC visits"
lab var ancpast_doc_home "Doctor at home"
lab var ancpast_doc_hosp "Doctor at Government hospital"
lab var ancpast_doc_clinic "Doctor at Private doctor/clinic"
lab var ancpast_doc_rhc "Doctor at SRHC-RHC"
lab var ancpast_doc_vill "Doctor at Routine ANC place within village/ward"
lab var ancpast_doc_eho "Doctor at EHO clinic"
lab var ancpast_doc_othplc "Doctor at other places"
lab var ancpast_doc_visit "Doctor - ANC visits"
lab var ancpast_nurs_home "Nurse at home"
lab var ancpast_nurs_hosp "Nurse at Government hospital"
lab var ancpast_nurs_clinic "Nurse at Private doctor/clinic"
lab var ancpast_nurs_rhc "Nurse at SRHC-RHC"
lab var ancpast_nurs_vill "Nurse at Routine ANC place within village/ward"
lab var ancpast_nurs_eho "Nurse at EHO clinic"
lab var ancpast_nurs_othplc "Nurse at other places"
lab var ancpast_nurs_visit "Nurse - ANC visits"
lab var ancpast_ha_home "HA at home"
lab var ancpast_ha_hosp "HA at Government hospital"
lab var ancpast_ha_clinic "HA at Private doctor/clinic"
lab var ancpast_ha_rhc "HA at SRHC-RHC"
lab var ancpast_ha_vill "HA at Routine ANC place within village/ward"
lab var ancpast_ha_eho "HA at EHO clinic"