***************************************************************************************** * Stata program for the conversion of data from the India NSS52 survey * from ASCII format to Stata format. * This program converts data from Schedule 1.0. * * Author: Akiko Sagesaka, World Bank Data Group (July 2013) ***************************************************************************************** clear set more off #delimit ; global pathin "L:\HHS\Datalib\India\IND_1995_NSS52-SCH1.0\IND_1995_NSS52-SCH1.0_v01_M\Data\Original"; global pathout "L:\HHS\Datalib\India\IND_1995_NSS52-SCH1.0\IND_1995_NSS52-SCH1.0_v01_M\Data\Stata"; tempfile tempR tempU; ***************************************************************; * SCHEDULE 1.0 - LEVEL 1 (Blocks 1,2 & 3) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B1_v15 34-36 str B1_v16 37 str B1_v17 38 str B1_v18 39 str B2_v02 40-42 str B2_v03 43-48 str B3_v01 49-50 str B3_v02a 51-56 str B3_v03 57 str B3_v04 58 str B3_v05 59-60 str B3_v06 61-67 str B3_v07 68 str B3_v08 69 str B3_v09 70 str B3_v10 71-76 str B3_v11 77-78 str B3_v12 79 str B3_v13 80 str B3_v14 81 str B3_v15 82 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="01"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; gen B3_v03a=B1_v02*10+B3_v03; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B1_v15 B1_v16 B1_v17 B1_v18 B2_v02 B2_v03 B3_v01 B3_v02a B3_v03 B3_v03a B3_v04 B3_v05 B3_v06 B3_v07 B3_v08 B3_v09 B3_v10 B3_v11 B3_v12 B3_v13 B3_v14 B3_v15 MLT_COMB MLT_SUB_SAMPLE; sort hhid; save "$pathout\NSS52_Sch1_bk_1_2_3", replace; ***************************************************************; * SCHEDULE 1.0 - LEVEL 2 (Block 10) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B10_v01 34 str B10_v02_1 35-36 str B10_v02_2 37-38 str B10_v02_3 39-40 str B10_v02_4 41-42 str B10_v02_5 43-44 str B10_v02_6 45-46 str B10_v02_7 47-48 str B10_v02_8 49-50 str B10_v02_9 51-52 str B10_v02_10 53-54 str B10_v02_11 55-56 str B10_v03 57 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="02"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B10_v01 B10_v02_1 B10_v02_2 B10_v02_3 B10_v02_4 B10_v02_5 B10_v02_6 B10_v02_7 B10_v02_8 B10_v02_9 B10_v02_10 B10_v02_11 B10_v03 MLT_COMB MLT_SUB_SAMPLE; sort hhid; save "$pathout\NSS52_Sch1_bk_10", replace; ***************************************************************; * SCHEDULE 1.0 - LEVEL 3 (Block 4) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B4_v01 30-32 str B4_v03 34 str B4_v04 35 str B4_v05 36-37 str B4_v06 38 str B4_v07 39-40 str B4_v08 41-42 str B4_v09 43 str B4_v10 44-45 str B4_v11 46 str B4_v12 47-48 str B4_v13 49 str B4_v14 50-51 str B4_v15 52 str B4_v16 53-54 str B4_v17 55-56 str B4_v18 57-58 str B4_v19 59-60 str B4_v20 61-62 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="03"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B4_v01 B4_v03 B4_v04 B4_v05 B4_v06 B4_v07 B4_v08 B4_v09 B4_v10 B4_v11 B4_v12 B4_v13 B4_v14 B4_v15 B4_v16 B4_v17 B4_v18 B4_v19 B4_v20 MLT_COMB MLT_SUB_SAMPLE; sort hhid B4_v01; save "$pathout\NSS52_Sch1_bk_4", replace; ***************************************************************; * SCHEDULE 1.0 - LEVEL 4 (Block 5 & 5.1) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B5_v01 30-32 str B5_v03 34-41 str B5_v04 42-49 str B5_v05 50-57 str B5_v06 58-65 str B5_v07 66-73 str B5_v08 74-81 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="04"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; loc item B5_v03 B5_v04 B5_v05 B5_v06 B5_v07 B5_v08; foreach x of varlist `item' {; replace `x'=`x'/100; }; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B5_v01 `item' MLT_COMB MLT_SUB_SAMPLE; sort hhid B5_v01; save "$pathout\NSS52_Sch1_bk_5_5-1", replace; ***************************************************************; * SCHEDULE 1.0 - LEVEL 5 (Block 6) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B6_v01 30-32 str B6_v03 34-41 str B6_v04 42-49 str B6_v05 50-57 str B6_v06 58-65 str B6_v07 66-73 str B6_v08 74-81 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="05"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; loc item B6_v03 B6_v04 B6_v05 B6_v06 B6_v07 B6_v08; foreach x of varlist `item' {; replace `x'=`x'/100; }; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B6_v01 `item' MLT_COMB MLT_SUB_SAMPLE; sort hhid B6_v01; save "$pathout\NSS52_Sch1_bk_6", replace; ***************************************************************; * SCHEDULE 1.0 - LEVEL 6 (Block 7) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B7_v01 30-32 str B7_v03 34-41 str B7_v04 42-49 str B7_v05 50-57 str B7_v06 58-65 str B7_v07 66-73 str B7_v08 74-81 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="06"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; loc item B7_v03 B7_v04 B7_v05 B7_v06 B7_v07 B7_v08; foreach x of varlist `item' {; replace `x'=`x'/100; }; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B7_v01 `item' MLT_COMB MLT_SUB_SAMPLE; sort hhid B7_v01; save "$pathout\NSS52_Sch1_bk_7", replace; ***************************************************************; * SCHEDULE 1.0 - LEVEL 7 (Block 8) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B8_v01 30-32 str B8_v03 34-41 str B8_v04 42-49 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="07"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; loc item B8_v03 B8_v04; foreach x of varlist `item' {; replace `x'=`x'/100; }; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B8_v01 `item' MLT_COMB MLT_SUB_SAMPLE; sort hhid B8_v01; save "$pathout\NSS52_Sch1_bk_8", replace; ***************************************************************; * SCHEDULE 1.0 - LEVEL 8 (Block 8.1 & 8.2) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B8_v01 30-32 str B8_v03 34-41 str B8_v04 42-49 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="08"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; loc item B8_v03 B8_v04; foreach x of varlist `item' {; replace `x'=`x'/100; }; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B8_v01 `item' MLT_COMB MLT_SUB_SAMPLE; append using "$pathout\NSS52_Sch1_bk_8"; sort hhid B8_v01; save "$pathout\NSS52_Sch1_bk_8", replace; ***************************************************************; * SCHEDULE 1.0 - LEVEL 9 (Block 9) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B9_v01 30-32 str B9_v02 33 str B9_v03 34-36 str B9_v04 37 str B9_v05 38-45 str B9_v06 46-53 str B9_v07 54-61 str B9_v08 62-69 str B9_v09 70-77 str B9_v10 78-85 str B9_v11 86-88 str B9_v12 89-96 str B9_v13 97-104 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="09"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; loc item B9_v02 B9_v03 B9_v04 B9_v05 B9_v06 B9_v07 B9_v08 B9_v09 B9_v10 B9_v11 B9_v12 B9_v13; foreach x of varlist `item' {; replace `x'=`x'/100; }; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B9_v01 `item' MLT_COMB MLT_SUB_SAMPLE; sort hhid B9_v01; save "$pathout\NSS52_Sch1_bk_9", replace; ***************************************************************; * SCHEDULE 1.0 - LEVEL 10 (Block 11.1) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B11_v01 30-32 str B11_v03 34 str B11_v04 35-42 str B11_v05 43-50 str B11_v06 51-58 str B11_v07 59-66 str B11_v08 67-74 str B11_v09 75-82 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="10"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B11_v01 B11_v03 B11_v04 B11_v05 B11_v06 B11_v07 B11_v08 B11_v09 MLT_COMB MLT_SUB_SAMPLE; sort hhid B11_v01; save "$pathout\NSS52_Sch1_bk_11-1", replace; ***************************************************************; * SCHEDULE 1.0 - LEVEL 11 (Block 11.2) ; ***************************************************************; foreach i in R U {; drop _all; infix str B1_v00 5-7 str B1_v06 8-10 str B1_v10 11 str Flot 12-16 str B1_v11 17-21 str B1_v12 22-24 str B1_v13 25 str B1_v14 26-27 str Level 28-29 str B11_v01 30-32 str B11_v03 34 str B11_v04 35-42 str B11_v05 43-50 str B11_v06 51-58 str B11_v07 59-66 str B11_v08 67-74 str B11_v09 75-82 str B1_v01 119 str B1_v02 120 str B1_v07 121-122 str B1_v08 123-124 str B1_v09 125 str MLT_SUB_SAMPLE 127-136 str MLT_COMB 137-146 using "$pathin\D146`i'.DAT"; keep if Level=="11"; compress; save `temp`i'', replace; }; use `tempR', clear; append using `tempU'; gen hhid= B1_v11+B1_v13+B1_v14; gen State=substr(B1_v06,1,2); destring *, replace; format hhid %15.0g; replace MLT_SUB_SAMPLE=MLT_SUB_SAMPLE/100; replace MLT_COMB=MLT_COMB/100; order hhid State Flot Level B1_v00 B1_v01 B1_v02 B1_v06 B1_v07 B1_v08 B1_v09 B1_v10 B1_v11 B1_v12 B1_v13 B1_v14 B11_v01 B11_v03 B11_v04 B11_v05 B11_v06 B11_v07 B11_v08 B11_v09 MLT_COMB MLT_SUB_SAMPLE; sort hhid B11_v01; save "$pathout\NSS52_Sch1_bk_11-2", replace;