*****************************************************************************************
* Stata program for the conversion of data from the India NSS48 survey
* from ASCII format to Stata format.
* This program converts data from Schedule 18.1 and adds variables and value labels.
*
* Author: Cathrine Machingauta, World Bank Data Group (November 2012)
*****************************************************************************************

clear
set more off


global pathout "Q:\India\IND_1992_NSS48-SCH18.1_v01_M\Data\ascii\sch18.1"
global pathout "Q:\India\IND_1992_NSS48-SCH18.1_v01_M\Data\Stata"

#delimit ;

***************************************************************;
* SCHEDULE 18.1 - Level 1- Blocks 1-5 - Visit 2                ;
***************************************************************;
local location R U;
foreach i in `location' {;

drop _all;
infix    
str	round	5-7
str	sample	8
str	visit	9
str	statereg	10-12
str	state	10-11
str	flot	13-17
str	block_No	18-22
str	substratum	23
str	hhno	24
str	level	25-26
str	S181B1_v20	27
str	psn_itm_No	28-30
str	record_No	31
str	S181B1_v16	32
str	S181B1_v17	33
str	S181B1_v18	34
str	S181B1_v19	35
str	S181B2_v2	36-41
str	S181B3_v1	42-43
str	S181B4_v1	44-45
str	S181B5_v1	46-47
str	S181B5_v2	48
str	S181B5_v3	49-54
str	S181B5_v4	55
str	S181B5_v5	56
str	S181B5_v6	57
str	S181B5_v7	58
str	S181B5_v8	59
str	S181B5_v9	60
str	S181B5_v10	61
str	S181B5_v11	62
str	S181B5_v12	63
str	sector	121
str	stratum	122-123
str	subsample	124
str	subround	125
str	MLT_subsample	151-160
str	MLT_combined	161-170


using "$pathin\D170V2`i'.TXT";

keep if level=="01";
gen hhid= block_No+substratum+hhno;
destring,replace;
format hhid %14.0f;
destring S181B5_v3, force replace;

la var	round	      "	Round Schedule";
la var	sample	      "	Sample";
la var	visit	      "	Visit No.";
la var	statereg	  "	State Region";
la var	state	      "	State";
la var	flot	      "	Flot No.";
la var	block_No	  "	Village/Block Srl.No.(fsu)";
la var	substratum	  "	Sub-stratum No.";
la var	hhno	      "	Sample HH No.";
la var	level	      "	Level No.";
la var	S181B1_v20	  "	Operational holding No./ Srl.No.of partitioned hh.";
la var	psn_itm_No	  "	Person/item /plot No.";
la var	record_No	  "	Type code/record No.";
la var	S181B1_v16	  "	Informant's relation to head";
la var	S181B1_v17	  "	Response code";
la var	S181B1_v18	  "	Survey code";
la var	S181B1_v19	  "	Reason for substitution";
la var	S181B2_v2	  "	Date of Survey";
la var	S181B3_v1	  "	No.of lines written (bl.3)";
la var	S181B4_v1	  "	No.of lines written (bl-4)";
la var	S181B5_v1	  "	Household Size";
la var	S181B5_v2	  "	Household Type (code)";
la var	S181B5_v3	  "	Industry-occupation";
la var	S181B5_v4	  "	Social group code";
la var	S181B5_v5	  "	Major crop season code";
la var	S181B5_v6	  "	Whether pesticides used during agr.Yr.1991-92(Y/N)";
la var	S181B5_v7	  "	Purpose of use";
la var	S181B5_v8	  "	Type of pesticides used for agriculture";
la var	S181B5_v9	  "	Type of pesticides used for other uses";
la var	S181B5_v10	  "	Whether the hh is partitioned";
la var	S181B5_v11	  "	No.of partitioned hh formed etc.";
la var	S181B5_v12	  "	No. of partitioned hh staying in the village/block";
la var	sector	      "	Sector";
la var	stratum	      "	Stratum";
la var	subsample	  "	Sub-sample";
la var	subround	  "	Sub-round";
la var	MLT_subsample "	Multiplier-I for sub-sample estimates";
la var	MLT_combined  "	Multiplier-II for combined estimates";

cap la de state 
2 "Andhra Pradesh"
3 "Assam"
4 "Bihar"
5 "Gujarat"
6 "Haryana"
7 "Himachal Pradesh"
8 "Jammu & Kashmir"
9 "Karnataka"
10"Kerala"
11"Madhya Pradesh"
12"Maharashtra"
13"Manipur"
14"Meghalaya"
15"Nagaland"
16"Orissa"
17"Punjab"
18"Rajasthan"
19"Sikkim"
20"Tamil Nadu"
21"Tripura"
22"Uttar Pradesh"
23"West Bengal"
24"A & N Islands"
25"Arunachal Pradesh"
26"Chandigarh"
27"Dadra & Nagar Haveli"
28"Delhi"
29"Goa"
30"Lakshdweep"
31"Mizoram"
32"Pondicherry"
33"Daman & Diu";
cap la val state state;

cap la de sector 
1 "Rural"
2 "Urban";
cap la val sector sector;
 
cap la def sample 
1"Central" 2 "State";
cap la val sample sample;

cap la def S181B1_v16
1 "Head of the household"
2 "Other member of the household"
9 "Others";
cap la val S181B1_v16 S181B1_v16;

cap la def S181B1_v17
1 "Informant co-operative and capable"
2 "Informant co-operative but not capable"
3 "Informant busy" 
4 "Informant reluctant"
5 "Others";
cap la val S181B1_v17 S181B1_v17;

cap la def S181B1_v18
1 "Original HH surveyed"
2 "Substitute HH surveyed"
3 "Casualty in 2nd visit"
4 "Casualty in 1st visit but originally selected hh in the 1st visit surveyed in 2nd visit";
cap la val S181B1_v18 S181B1_v18;

cap la def S181B1_v19
1 "Informants busy"
2 "Members away from home"
3 "Informant non-cooperative"
9 "Others";
cap la val S181B1_v19 S181B1_v19;


cap la def S181B5_v2
1 "Rural:Self empl in non agric.Urban:Self Empl"
2 "Rural: Agric labour.Urban:Regular wage/salary earnings"
3 "Rural:Other labour.Urban:Casual labour"
4 "Rural:Self employed in agriculture"
9 "Rural: Others. Urban: Others";
cap la val S181B5_v2 S181B5_v2;

cap la def S181B5_v4
1 "Scheduled tribe"
2 "Scheduled caste/neo-Buddhist"
9 "Others";
cap la val S181B5_v4 S181B5_v4;

cap la def S181B5_v5
1 "Kharif" 2 "Rabi";
cap la val S181B5_v5 S181B5_v5;

foreach x in S181B5_v6 S181B5_v10 {;
cap la def `x' 1 "Yes" 2"No";
cap la val `x' `x';
};

cap la def S181B5_v7
1"Agricultural" 2"Others" 3"Both";
cap la val S181B5_v7 S181B5_v7;

cap la def S181B5_v8
1"Insecticides"
2"Pyrethroids"
3"Synthetic fungicides"
4"Weedcides"
5"Rodenticides & fumigants"
6"Acaricide"
7"Plant growth regulants";
cap la val S181B5_v8 S181B5_v8;

 save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

isid hhid;
order hhid state;
sort hhid state;
compress ;

saveold "$pathout\NSS48_Sch181_V2_bk1_5.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";


***************************************************************;
* SCHEDULE 18.1 - Level 2- Block 5.1 -  Visit 2                  ;
***************************************************************;

local location R U;
foreach i in `location' {;

drop _all;
infix    
str	round	5-7
str	sample	8
str	visit	9
str	statereg	10-12
str	state	10-11
str	flot	13-17
str	block_No	18-22
str	substratum	23
str	hhno	24
str	level	25-26
str	S181B51_v1	27
str	psn_itm_No	28-30
str	record_No	31
str	S181B51_v3	32-33
str	S181B51_v4	34
str	S181B51_v5	35
str	MLT_subsample	151-160
str	MLT_combined	161-170
using "$pathin\D170V2`i'.TXT";

keep if level=="02";
gen hhid= block_No+substratum+hhno;
gen sector="`i'";
replace sector="1" if sector=="R";
replace sector="2" if sector=="U";
destring,replace;
format hhid %14.0f;

la var	hhid 	      "Household ID";
la var	round	      "Round Schedule";
la var	sample	      "Sample";
la var  sector        "Sector";
la var	visit	      "Visit No.";
la var	statereg	  "State Region";
la var	state	      "State";
la var	flot	      "Flot No.";
la var	block_No	  "Village/Block Srl.No.(fsu)";
la var	substratum	  "Sub-stratum No.";
la var	hhno	      "Sample HH No.";
la var	level	      "Level No.";
la var	S181B51_v1	  "Srl. no.of partitioned hh/operational holding No.";
la var	psn_itm_No	  "Item/person/plot no.";
la var	record_No	  "Type code/Record No.";
la var	S181B51_v3	  "No. of members of partitioned hh";
la var	S181B51_v4	  "Whether the partitioned hh formed before 30.6.92 (yes/no)";
la var	S181B51_v5	  "Whether any area operated by hh.";
la var	MLT_subsample "Multiplier-I for sub-sample estimates";
la var	MLT_combined  "Multiplier-II for combined estimates";

foreach x in sample state sector {;
la val `x' `x';
};

foreach x in S181B51_v4 S181B51_v5 {;
cap la def `x' 1"Yes" 2"No";
cap la val `x' `x';
};


save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

isid hhid S181B51_v1;
order  hhid S181B51_v1 state;
sort hhid state;
compress ;

saveold "$pathout\NSS48_Sch181_V2_bk51.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";

***************************************************************;
* SCHEDULE 18.1 - Level 3 - Block 9 -  Visit 2                ;
***************************************************************;

local location R U;
foreach i in `location' {;

drop _all;
infix    
str	round	      5-7
str	sample	      8
str	visit	      9
str	statereg	  10-12
str	state	      10-11
str	flot	      13-17
str	block_No	  18-22
str	substratum	  23
str	hhno	      24
str	level	      25-26
str	holding_No	  27
str	plot_No	      28-30
str	record_No	  31
str	S181B9_v1     32
str	S181B9_v2	  33
str	S181B9_v3	  34-36
str	S181B9_v5	  37
str	S181B9_v6	  38-42
str	S181B9_v7	  43-45
str	S181B9_v8	  46-50
str	S181B9_v9	  51-55
str	S181B9_v10	  56
str	S181B9_v11	  57
str	S181B9_v12	  58
str	S181B9_v13	  59
str	S181B9_v14	  60-64
str	S181B9_v15	  65-69
str	S181B9_v16	  70-74
str	S181B9_v17	  75-79
str	S181B9_v18	  80-84
str	S181B9_v19	  85-89
str	S181B9_v20	  90-94
str	S181B9_v21	  95
str	S181B9_v22	  96-100
str	S181B9_v23	  101-105
str	S181B9_v24	  106-110
str	S181B9_v25	  111-115
str	S181B9_v26	  116
str	S181B9_v27	  117
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V2`i'.TXT";

keep if level=="03";
gen hhid= block_No+substratum+hhno;
gen sector="`i'";
replace sector="1" if sector=="R";
replace sector="2" if sector=="U";
destring,replace;
format hhid %14.0f;

la var	hhid 	      "Household ID";
la var  sector        "Sector";
la var	round	      "Round Schedule";
la var	sample	      "Sample";
la var	visit	      "Visit No.";
la var	statereg	  "State Region";
la var	state	      "State";
la var	flot	      "Flot No.";
la var	block_No	  "Village/Block Srl.No.(fsu)";
la var	substratum	  "Sub-stratum No.";
la var	hhno	      "Sample HH No.";
la var	level	      "Level No.";
la var	holding_No	  "Operational holding No.";
la var	plot_No	      "Srl. No. of plot";
la var	record_No	  "Type code/record No.";
la var	S181B9_v1     "Srl.No.of partitioned hh as in block 9, visit-I, sch";
la var	S181B9_v2	  "Operational holding No.";
la var	S181B9_v3	  "Srl. no. of plot";
la var	S181B9_v5	  "Location code";
la var	S181B9_v6	  "Geographical area (in 0.00 acres)";
la var	S181B9_v7	  "% area operated";
la var	S181B9_v8	  "Actual area operated (0.00 acres)";
la var	S181B9_v9	  "If owned,area (0.00 acres)";
la var	S181B9_v10	  "If leased in (srl. no. 14 to19), Whether lease is recorded";
la var	S181B9_v11	  "Period of lease code	";
la var	S181B9_v12	  "Lessor type code";
la var	S181B9_v13	  "Terms of lease";
la var	S181B9_v14	  "Area (0.00  acres)";
la var	S181B9_v15	  "Area of land otherwise possessed (0.00 acres)";
la var	S181B9_v16	  "Area water logged with drainage facility (0.00 acres)";
la var	S181B9_v17	  "Area water logged without drainage facility (0.00 acres)";
la var	S181B9_v18	  "Area under utilisation - Forest (0.00 acres)";
la var	S181B9_v19	  "Net sown area : Unirrigated area  (0.00 acres)";
la var	S181B9_v20	  "Net sown area: Irrigated area  (0.00 acres)";
la var	S181B9_v21	  "Irrigated (source)";
la var	S181B9_v22	  "Fallow during Rabi (0.00 acres)";
la var	S181B9_v23	  "Water bodies used for pisiculture (0.00 acres)";
la var	S181B9_v24	  "Other non-agr.uses (0.00 acres)";
la var	S181B9_v25	  "Others (0.00 acres)";
la var	S181B9_v26	  "Whether any agr.production carried out";
la var	S181B9_v27	  "Whether possessed for major part of agr.year";
la var	MLT_subsample "Multiplier-I for sub-sample estimates";
la var	MLT_combined  "Multiplier-II for combined estimates";

foreach x in sample state sector {;
la val `x' `x';
};

foreach x in S181B9_v10 S181B9_v26 S181B9_v27 {;
cap la def `x' 1"Yes" 2 "No";
cap la val `x' `x';
};

cap la def S181B9_v5
1"Urban: Within sample town. Rural:Within village"
2"Urban: Outside sample town but within state.Rural:Outside village but within patwari circle"
3"Urban: Outside state.Rural:Outside patwari circle but within revenue inspector's circle"
4"Urban:Within state.Rural:Outside revenue inspector's circle but within tehsil"
5"Urban: Outside state.Rural:Outside tehsil but within district"
6"Rural:Outside district but within state"
7"Rural:Outside state"
8"Urban:Within state"
9"Urban:Outside state";
cap la val S181B9_v5 S181B9_v5;

cap la def S181B9_v11
1 "Less than an agricultural season"
2 "At least 1 agric season but less than an agric year"
3 "At least 1 agric year but less than 2 agric years"
4 "At least 2 agric years but less than 5 agric years"
5 "At least 5 agric years but less than 12 agric years"
6 "12 years or more";
cap la val S181B9_v11 S181B9_v11;

cap la def S181B9_v12
1 "Urban:Cultivating households within sample town.Rural:Cultivating households-within the sample village."
2 "Urban:Cultivating households-other urban areas.Rural:Cultivating households-other rural areas."
3 "Urban:Other urban households.Rural:Other rural households"
4 "Urban:Rural households.Rural:Urban households"
9 "Urban:Others.Rural:Others";
cap la val S181B9_v12 S181B9_v12;

cap la def S181B9_v13
1"For fixed money"
2"For fixed produce"
3"For share of produce"
4"For service contract"
5"For share of produce together with other terms"
6"Under usufructuary mortgage"
7"From relatives under no specified terms"
9"Under other terms";
cap la val S181B9_v13 S181B9_v13;

cap la def S181B9_v21
1"Canal"
2"Tank"
3"Tubewell"
4"Well"
9"Others";
cap la val S181B9_v21 S181B9_v21;

save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";


order S181B9_v1 hhid state;
sort S181B9_v1 hhid state;
compress ;

saveold "$pathout\NSS48_Sch181_V2_bk9.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";

***************************************************************;
* SCHEDULE 18.1 - Level 4 - Block 9.1 -   Visit 2           ;
***************************************************************;

local location R U;
foreach i in `location' {;

drop _all;
infix
str	round	      5-7
str	sample	      8
str	visit	      9
str	statereg	  10-12
str	state	      10-11
str	flot	      13-17
str	block_No	  18-22
str	substratum	  23
str	hhno	      24
str	level	      25-26
str	S181B9_v2	  27
str	S181B91_v1	  28-30
str	record_No	  31
str	S181B91_v0	  32
str	S181B91_v2	  33-35
str	S181B91_v4	  36
str	S181B91_v5	  37-41
str	S181B91_v6	  42-44
str	S181B91_v7	  45-49
str	S181B91_v8	  50-54
str	S181B91_v9	  55-59
str	S181B91_v10	  60-64
str	S181B91_v11	  65
str	MLT_subsample 151-160
str	MLT_combined  161-170
using "$pathin\D170V2`i'.TXT";
   
keep if level=="04";
gen hhid= block_No+substratum+hhno;
gen sector="`i'";
replace sector="1" if sector=="R";
replace sector="2" if sector=="U";
destring,replace;
format hhid %14.0f;

la var	hhid 	      "Household ID";
la var  sector		  "Sector";
la var	round	      "Round Schedule";
la var	sample	      "Sample";
la var	visit	      "Visit No.";
la var	statereg	  "State Region	";
la var	state	      "State";
la var	flot	      "Flot No.";
la var	block_No	  "Village/Block Srl.No.(fsu)";
la var	substratum	  "Sub-stratum No.";
la var	hhno	      "Sample HH No.";
la var	level	      "Level No.";
la var	S181B9_v2	  "Operational holding No.";
la var	S181B91_v1	  "Srl.No.of plot";
la var	record_No	  "Type code/record No.";
la var	S181B91_v0	  "If joint, no. of partners hh";
la var	S181B91_v2	  "Srl.no. of plot as in Bl.9 of visit-1 sch.";
la var	S181B91_v4	  "Location code";
la var	S181B91_v5	  "Geographical area (0.00 acres)";
la var	S181B91_v6	  "% of area operated";
la var	S181B91_v7	  "Actual area operated-Owned (0.00 acres)";
la var	S181B91_v8	  "Actual area operated - Leased in (0.00 acres)";
la var	S181B91_v9	  "Actual area Otherwise possessed (0.00 acres)";
la var	S181B91_v10	  "Total (0.00 acres)";
la var	S181B91_v11	  "Whether possessed for major part of agrl year";
la var	MLT_subsample "Multiplier-I for sub-sample estimates";
la var	MLT_combined  "Multiplier-II for combined estimates";

foreach x in sample state sector {;
la val `x' `x';
};

cap la def S181B91_v4
1"Urban: Within sample town. Rural:Within village"
2"Urban: Outside sample town but within state.Rural:Outside village but within patwari circle"
3"Urban: Outside state.Rural:Outside patwari circle but within revenue inspector's circle"
4"Urban:Within state.Rural:Outside revenue inspector's circle but within tehsil"
5"Urban: Outside state.Rural:Outside tehsil but within district"
6"Rural:Outside district but within state"
7"Rural:Outside state"
8"Urban:Within state"
9"Urban:Outside state";
cap la val S181B91_v4 S181B91_v4;

save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

*isid hhid S181B91_v1 ;
order hhid state;
sort  hhid state;
compress ;

saveold "$pathout\NSS48_Sch181_V2_bk91.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";

***************************************************************;
* SCHEDULE 18.1 - Level 5 - Block 10 -  Visit 2               ;
***************************************************************;

local location R U;
foreach i in `location' {;

drop _all;
infix
str	round	      5-7
str	sample	      8
str	visit	      9
str	statereg	  10-12
str	state	      10-11
str	flot	      13-17
str	block_No	  18-22
str	substratum	  23
str	hhno	      24
str	level	      25-26
str	S181B10_v1	  27
str	psn_itm_No	  28-30
str	record_No	  31
str	S181B10_v0	  32
str	S181B10_v2	  33
str	S181B10_v3	  34
str	S181B10_v4	  35
str	S181B10_v5	  36
str	S181B10_v6	  37
str	S181B10_v7	  38
str	S181B10_v8	  39
str	S181B10_v9	  40
str	S181B10_v10	  41
str	S181B10_v11	  42
str	S181B10_v12	  43
str	S181B10_v13	  44
str	S181B10_v14	  45
str	S181B10_v15   46
str	S181B10_v16	  47-48
str	S181B10_v17	  49-52
str	S181B10_v18	  53-54
str	S181B10_v19	  55-57
str	S181B10_v20	  145-150
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V2`i'.TXT";

keep if level=="05";
gen hhid= block_No+substratum+hhno;
gen sector="`i'";
replace sector="1" if sector=="R";
replace sector="2" if sector=="U";
destring,replace;
format hhid %14.0f;

la var	hhid 	      "	Household ID";
la var	sector	      "	Sector";
la var	round	      "	Round Schedule";
la var	sample	      "	Sample";
la var	visit	      "	Visit No.";
la var	statereg	  "	State Region";
la var	state	      "	State";
la var	flot	      "	Flot No.";
la var	block_No	  "	Village/Block Srl.No.(fsu)";
la var	substratum	  "	Sub-stratum No.";
la var	hhno	      "	Sample HH No.";
la var	level	      "	Level No.";
la var	S181B10_v1	  "	Operational holding No.";
la var	psn_itm_No	  "	Item/person/plot no.";
la var	record_No	  "	Type code/record no. of partner hh";
la var	S181B10_v0	  "	Srl. no. of partitioned hh";
la var	S181B10_v2	  "	How operated";
la var	S181B10_v3	  "	If jointly, no.of partner hh";
la var	S181B10_v4	  "	Class of area operated";
la var	S181B10_v5	  "	Type of holding";
la var	S181B10_v6	  "	Main use of the holding";
la var	S181B10_v7	  "	In homestead: Cultivation in kitchen garden carried during Rabi";
la var	S181B10_v8	  "	Livestock keeping during Rabi";
la var	S181B10_v9	  "	Poultry during Rabi";
la var	S181B10_v10	  "	Other agr.production during Rabi";
la var	S181B10_v11	  "	Outside homestead land : Orchards during Rabi";
la var	S181B10_v12	  "	Plantations during Rabi";
la var	S181B10_v13	  "	Raising field crops during Rabi";
la var	S181B10_v14	  "	Pisiculture during Rabi";
la var	S181B10_v15	  "	Other agrl. Production during Rabi";
la var	S181B10_v16	  "	No.of parcels in holding";
la var	S181B10_v17	  "	Distance of farthest parcel from residence";
la var	S181B10_v18	  "	No. of parcels in the cultivated area of the holding";
la var	S181B10_v19	  "	No.of permanent attached farm workers during the season against payment of wages";
la var	S181B10_v20	  "	No.of permanent attached farm workers during the season against share of produce";
la var	MLT_subsample "	Multiplier-I for sub-sample estimates";
la var	MLT_combined  "	Multiplier-II for combined estimates";

foreach x in sample state sector {;
la val `x' `x';
};

cap la def S181B10_v2
1 "Individually" 2"Jointly";
cap la val S181B10_v2 S181B10_v2;

cap la def S181B10_v4
1"0.00-0.09"
2"0.10-0.99"
3"1.00-9.99"
4"10.00-99.99"
5"100.00 & above";
cap la val S181B10_v4 S181B10_v4;

cap la def S181B10_v5
1"Entirely owned"
2"Entirely leased-in"
3"Both owned and leased-in"
4"Entirely otherwise possessed";
cap la val S181B10_v5 S181B10_v5;

cap la def S181B10_v6
1"Crop production other than vegetables"
2"Vegetables"
3"Horticulture crop/orchards"
4"Plantation crop other than forestry plantation"
5"Forestry plantation"
6"Livestock keeping"
7"Poultry raising"
8"Pisciculture"
9"Others";
cap la val S181B10_v6 S181B10_v6;

foreach var of varlist S181B10_v7-S181B10_v15 {;
cap la def `var' 1"Yes" 2"No";
cap la val `var' `var';
};


save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

order hhid state sector;
sort hhid state;
compress ;

saveold "$pathout\NSS48_Sch181_V2_bk10.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";

***************************************************************;
* SCHEDULE 18.1 - Level 6 - Block 14 -  Visit 2            ;
***************************************************************;

local location R U;
foreach i in `location' {;

drop _all;
infix
str	round	      5-7
str	sample	      8
str	visit	      9
str	statereg	  10-12
str	state	      10-11
str	flot	      13-17
str	block_No	  18-22
str	substratum	  23
str	hhno	      24
str	level	      25-26
str	S181B14_vi	  27
str	S181B14_v1	  28-30
str	record_No	  31
str	S181B14_vii	  32
str	S181B14_v2	  33
str	S181B14_v3	  34-36
str	S181B14_v5	  37-41
str	S181B14_v6	  42-46
str	S181B14_v7	  47
str	S181B14_v8	  48
str	S181B14_v9	  49
str	S181B14_v10	  50-54
str	S181B14_v11	  55-59
str	S181B14_v12	  60-64
str	S181B14_v13	  65
str	S181B14_v14	  66-70
str	S181B14_v15	  71-75
str	S181B14_v16   76-80
str	S181B14_v17	  81-85
str	S181B14_v18	  86-90
str	S181B14_v19	  91-95
str	S181B14_v20	  96-100
str	S181B14_v21	  101-105
str	S181B14_v22	  106-110
str	S181B14_v23	  111-115
str	S181B14_v24	  116
str	S181B14_v25	  117
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V2`i'.TXT";

keep if level=="06";
gen hhid= block_No+substratum+hhno;
gen sector="`i'";
replace sector="1" if sector=="R";
replace sector="2" if sector=="U";
destring,replace;
format hhid %14.0f;

la var	hhid 	      "Household ID";
la var	sector	      "Sector";
la var	round	      "	Round Schedule";
la var	sample	      "	Sample";
la var	visit	      "	Visit No.";
la var	statereg	  "	State Region";
la var	state	      "	State";
la var	flot	      "	Flot No.";
la var	block_No	  "	Village/Block Srl.No.(fsu)";
la var	substratum	  "	Sub-stratum No.";
la var	hhno	      "	Sample HH No.";
la var	level	      "	Level No.";
la var	S181B14_vi	  "	Operational holding No.";
la var	S181B14_v1	  "	Srl.No.of plot";
la var	record_No	  "	Type code/record no.";
la var	S181B14_vii	  "	If joint, no.of partner hhs as in block or 9.1 of visit-II";
la var	S181B14_v2	  "	Operational holding no.";
la var	S181B14_v3	  "	Srl.no. of plot as in bl.9/9.1";
la var	S181B14_v5	  "	Actual area operated (0.00 acres)";
la var	S181B14_v6	  "	If owned, area (0.00 acres)";
la var	S181B14_v7	  "	If leased-in : Period of lease code";
la var	S181B14_v8	  "	Lessor type code";
la var	S181B14_v9	  "	Terms of lease";
la var	S181B14_v10	  "	Area (0.00 acres)";
la var	S181B14_v11	  "	Area otherwise possessed (0.00 acres)";
la var	S181B14_v12	  "	Area by land use : Forest (0.00 acres)";
la var	S181B14_v13	  "	Irrigated:-Source code";
la var	S181B14_v14	  "	Irrigated:-Cropped once(area)";
la var	S181B14_v15	  "	Irrigated:-Cropped twice(area)";
la var	S181B14_v16	  "	Irrigated:-Cropped more than twice (area)";
la var	S181B14_v17	  "	Unirrigated:-Cropped once";
la var	S181B14_v18	  "	Unirrigated:-Cropped more than once";
la var	S181B14_v19	  "	Unirrigated:-Current fallow";
la var	S181B14_v20	  "	Unirrigated:-Other fallow";
la var	S181B14_v21	  "	Water bodies for pisiculture";
la var	S181B14_v22	  "	Other non-agr.uses";
la var	S181B14_v23	  "	Others";
la var	S181B14_v24	  "	Kharif";
la var	S181B14_v25	  "	Rabi";
la var	MLT_subsample "	Multiplier-I for sub-sample estimates";
la var	MLT_combined  "	Multiplier-II for combined estimates";


foreach x in sample state sector {;
la val `x' `x';
};

cap la def S181B14_v7
1 "Less than an agricultural season"
2 "At least 1 agric season but less than an agric year"
3 "At least 1 agric year but less than 2 agric years"
4 "At least 2 agric years but less than 5 agric years"
5 "At least 5 agric years but less than 12 agric years"
6 "12 years or more";
cap la val S181B14_v7 S181B14_v7;

cap la def S181B14_v8
1 "Urban:Cultivating households within sample town.Rural:Cultivating households-within the sample village."
2 "Urban:Cultivating households-other urban areas.Rural:Cultivating households-other rural areas."
3 "Urban:Other urban households.Rural:Other rural households"
4 "Urban:Rural households.Rural:Urban households"
9 "Urban:Others.Rural:Others";
cap la val S181B14_v8 S181B14_v8;

cap la def S181B14_v9
1"For fixed money"
2"For fixed produce"
3"For share of produce"
4"For service contract"
5"For share of produce together with other terms"
6"Under usufructuary mortgage"
7"From relatives under no specified terms"
9"Under other terms";
cap la val S181B14_v9 S181B14_v9;

cap la def S181B14_v13
1"Canal"
2"Tank"
3"Tubewell"
4"Well"
9"Others";
cap la val S181B14_v13 S181B14_v13;

save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

order hhid state sector;
sort hhid state block;
compress ;

saveold "$pathout\NSS48_Sch181_V2_bk14.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";


***************************************************************;
* SCHEDULE 18.1 - Level 7 - Block 15 - Visit 2                 ;
***************************************************************;

local location R U;
foreach i in `location' {;

drop _all;
infix
str	round	      5-7
str	sample	      8
str	visit	      9 
str	statereg	  10-12
str	state	      10-11
str	flot	      13-17
str	block_No	  18-22
str	substratum	  23
str	hhno	      24
str	level	      25-26
str	S181B15_v1	  27
str	psn_itm_No	  28-30
str	record_No	  31
str	S181B15_v2	  32
str	S181B15_v3	  33
str	S181B15_v4	  34
str	S181B15_v5	  35
str	S181B15_v6	  36
str	S181B15_v7	  37
str	S181B15_v8	  38
str	S181B15_v9	  39
str	S181B15_v11	  41
str	S181B15_v12	  42
str	S181B15_v13	  43
str	S181B15_v14	  44
str	S181B15_v15	  45
str	S181B15_v16   46-50
str	S181B15_v17	  51-55
str	S181B15_v18	  56-57
str	S181B15_v19	  58-61
str	S181B15_v20	  62-63
str	S181B15_v21	  64-65
str	S181B15_v22	  66-67
str	MLT_subsample 151-160
str	MLT_combined  161-170
using "$pathin\D170V2`i'.TXT";

keep if level=="07";
gen hhid= block_No+substratum+hhno;
gen sector="`i'";
replace sector="1" if sector=="R";
replace sector="2" if sector=="U";
destring,replace;
format hhid %14.0f;

la var	hhid 	      "Household ID";
la var	sector	      "Sector";
la var	round	      "Round Schedule";
la var	sample	      "Sample";
la var	visit	      "Visit No.";
la var	statereg	  "State Region";
la var	state	      "State";
la var	flot	      "Flot No.";
la var	block_No	  "Village/Block Srl.No. (fsu)";
la var	substratum	  "Sub-stratum No.";
la var	hhno	      "Sample HH No.";
la var	level	      "Level No.";
la var	S181B15_v1	  "Operational holding No.";
la var	psn_itm_No	  "Item/person/plot No.";
la var	record_No	  "Type code/record No.";
la var	S181B15_v2	  "How operated";
la var	S181B15_v3	  "If jointly no. of partner hh";
la var	S181B15_v4	  "Class of area operated";
la var	S181B15_v5	  "Type of holding";
la var	S181B15_v6	  "Main use of the holding";
la var	S181B15_v7	  "Whether Crop cultivation in kitchen garden was carried out in homestead during 1991-92.";
la var	S181B15_v8	  "Whether Livestock keeping was carried out in homestead during 1991-92.";
la var	S181B15_v9	  "Whether Poultry production was carried out in homestead during 1991-92.";
la var	S181B15_v11	  "Orchards outside homestead";
la var	S181B15_v12	  "Plantations outside homestead";
la var	S181B15_v13	  "Raising field crops outside homestead";
la var	S181B15_v14	  "Pisiculture outside homestead";
la var	S181B15_v15	  "Other agrl. Production outside homestead";
la var	S181B15_v16   "Area of holding looked after by others for holders residing elsewhere: Rural areas (0.00 acres)";
la var	S181B15_v17	  "Area of holding looked after by others for holders residing elsewhere: Urban areas (0.00 acres)";
la var	S181B15_v18	  "No.of parcels in the holding";
la var	S181B15_v19	  "Distance of farthest parcel from residence (km.)";
la var	S181B15_v20	  "No. of parcels in the cultivated area of the holding";
la var	S181B15_v21	  "No.of permanent farm workers during 1991-92 against payment of wages";
la var	S181B15_v22	  "No.of permanent farm workers during 1991-92 against payment of produce";
la var	MLT_subsample "Multiplier-I for sub-sample estimates";
la var	MLT_combined  "Multiplier-II for combined estimates";

foreach x in sample state sector {;
la val `x' `x';
};

cap la def S181B15_v2
1 "Individually" 2 "Jointly";
cap la val S181B15_v2 S181B15_v2;

cap la def S181B15_v4
1 "0.00-009 acres"
2 "0.10-0.99 acres"
3 "1.00-9.99 acres"
4 "10.00-99.99 acres"
5 "100 acres & above";
cap la val S181B15_v4 S181B15_v4;

cap la def S181B15_v5
1 "Entirely owned"
2 "Entirely leased-in"
3 "Both owned & leased-in"
4 "Entirely otherwise possessed";
cap la val S181B15_v5 S181B15_v5;

cap la def S181B15_v6
1 "Crop production-other than vegetables"
2 "Crop production-vegetables"
3 "Horticulture crops/orchards"
4 "Plantation crops (other than forestry plantation"
5 "Forestry plantation"
6 "Livestock keeping"
7 "Poultry raising"
8 "Pisciculture"
9 "Others";
cap la val S181B15_v6 S181B15_v6;

foreach var of varlist S181B15_v7-S181B15_v15 {;
cap la def `var' 1"Yes" 2"No";
cap la val `var' `var';
};


save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

order hhid state sector;
sort hhid state block;
compress ;

saveold "$pathout\NSS48_Sch181_V2_bk15.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";


***************************************************************;
* SCHEDULE 18.1 - Level 8 - Block 16 - Visit 2               ;
***************************************************************;

local location R U;
foreach i in `location' {;

drop _all;
infix
str	round	      5-7
str	sample	      8
str	visit	      9
str	statereg	  10-12
str	state	      10-11
str	flot	      13-17
str	block_No	  18-22
str	substratum	  23
str	hhno	      24
str	level	      25-26
str	holding_No	  27
str	S181B16_v1	  28-30
str	record_No	  31
str	S181B16_v3	  32-34
str	S181B16_v4	  35-37
str	S181B16_v5	  38-40
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V2`i'.TXT";

keep if level=="08";
gen hhid= block_No+substratum+hhno;
gen sector="`i'";
replace sector="1" if sector=="R";
replace sector="2" if sector=="U";
destring,replace;
format hhid %14.0f;

la var	hhid 	      "Household ID";
la var  sector        "Sector";
la var	round	      "Round Schedule";
la var	sample	      "Sample";
la var	visit	      "Visit No.";
la var	statereg	  "State Region";
la var	state	      "State";
la var	flot	      "Flot No.";
la var	block_No	  "Village/Block Srl.No.(fsu)";
la var	substratum	  "Sub-stratum No.";
la var	hhno	      "Sample HH No.";
la var	level	      "Level No.";
la var	holding_No	  "Operational holding No.";
la var	S181B16_v1	  "Type of wood code";
la var	record_No	  "Type code/record No.";
la var	S181B16_v3	  "No. of trees standing-Grown during last 365 days";
la var	S181B16_v4	  "No. of trees standing for more than 1 year";
la var	S181B16_v5	  "No. of trees felled/ exploited during last last 365 days";
la var	MLT_subsample "Multiplier-I for sub-sample estimates";
la var	MLT_combined  "Multiplier-II for combined estimates";

foreach x in sample state sector {;
la val `x' `x';
};

cap la def S181B16_v1
1 "Mango"
2 "Jammon"
3 "Neem"
4 "Jack fruit"
5 "Babool"
6 "Teak"
7 "Shishum"
8 "Sal"
9 "Deodar"
10"Chir"
11"Kail"
12"Eucalyptus"
13"Pulp & Match wood"
14"Poplar"
15"Bamboo"
16"Other(specify)"
cap la val S181B16_v1 S181B16_v1;

save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

order hhid state sector;
sort hhid state;
compress ;

saveold "$pathout\NSS48_Sch181_V2_bk16.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";
