*****************************************************************************************
* 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 1                ;
***************************************************************;
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	psn_itm_No	  28-30
str	type_code	  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-60
str	S181B5_v7	  61
str	S181B5_v8	  62
str	S181B5_v9	  63-67
str	S181B5_v10	  68
str	S181B5_v11	  69-73
str	S181B5_v12	  74
str	S181B5_v13	  75-79
str	S181B5_v14	  80
str	S181B5_v15	  81-85
str	S181B5_v16	  86
str	S181B5_v17 	  87
str	S181B5_v18	  88-92
str	S181B5_v19	  93-97
str	S181B5_v20	  98
str	S181B5_v21	  99
str	S181B5_v22	  100
str	S181B5_v23	  101
str	S181B5_v24	  102
str	sector	      121
str	stratum	      122-123
str	subsample	  124
str	subround	  125
str	update_code	  126
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V1`i'.TXT";

keep if level=="01";
gen hhid= block_No+substratum+hhno;
destring,replace;
format hhid %14.0f;
destring S181B5_v3, force replace;  

label var   hhid          "Household ID";
label var	round	      "Round Schedule";
label var	sample	      "Sample";
label var	visit 	      "Visit No.";
label var	statereg	  "State Region";
label var   state         "State";
label var	flot	      "Flot No.";
label var	block_No      "Village/Block Srl.No.(fsu)";
label var	substratum	  "Sub-stratum No.";
label var	hhno	      "Sample HH No.";
label var	level	      "Level No.";
label var	holding_No	  "Operational holding No./srl.No.of partitioned HH";
label var	psn_itm_No	  "Person/item /plot No.";
label var	type_code	  "Type code/Srl.No.";
label var	S181B1_v16	  "Informant's relation to head";
label var	S181B1_v17	  "Response code";
label var	S181B1_v18	  "Survey code";
label var	S181B1_v19	  "Reason for substitution";
label var	S181B2_v2	  "Date of Survey";
label var	S181B3_v1	  "No.of lines written (bl.3)";
label var	S181B4_v1	  "No.of lines written (bl-4)";
label var	S181B5_v1	  "Household Size";
label var	S181B5_v2	  "Household Type (code)";
label var	S181B5_v3	  "Industry occupation";
label var	S181B5_v4	  "Social group code";
label var	S181B5_v5	  "Whether HH possesses homestead land";
label var	S181B5_v6	  "If yes, area of homestead land (0.00 acres)";
label var	S181B5_v7	  "Possession type of homestead";
label var	S181B5_v8	  "Whether HH own any land other than homestead";
label var	S181B5_v9	  "If yes,area (0.00 acres)";
label var	S181B5_v10	  "Whether land leased-out";
label var	S181B5_v11	  "If yes, area leased-out (0.00 acres)";
label var	S181B5_v12	  "Whether any land other than homestead,leased-in";
label var	S181B5_v13	  "If yes, area leased in (0.00 acres)";
label var	S181B5_v14	  "Whether otherwise possessed";
label var	S181B5_v15	  "If yes, area otherwise possessed (0.00 acres)";
label var	S181B5_v16	  "Whether HH has domestic servant, paying-guest etc.";
label var	S181B5_v17	  "If yes, whether they own any land";
label var	S181B5_v18	  "If Yes,area owned by them (0.00 acres)";
label var	S181B5_v19	  "Land owned/retained but not accessible (0.00 acres)";
label var	S181B5_v20	  "Crop Production in Kitchen garden";
label var	S181B5_v21	  "Livestock keeping";
label var	S181B5_v22	  "Poultry farming";
label var	S181B5_v23	  "Other Agrl. Production";
label var	S181B5_v24	  "Whether Agrl. Production carried-out/intended in any season";
label var	sector	      "Sector";
label var	stratum	      "Stratum";
label var	subsample	  "Sub-sample";
label var	subround	  "Sub-round";
label var	update_code	  "Update code";
label var	MLT_subsample "Multiplier-I for sub-sample estimates";
label 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";
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;

foreach x in S181B5_v5 S181B5_v8 S181B5_v10 S181B5_v12 S181B5_v14 ///
S181B5_v16 S181B5_v17 S181B5_v20 S181B5_v21 S181B5_v22 S181B5_v23 {;
cap la def `x'
1 "Yes"
2 "No";
cap la val `x' `x';
};

cap la def S181B5_v7
1 "Owned"
2 "Leased-in "
3 "Otherwise possessed";
cap la val S181B5_v7 S181B5_v7;

cap la def S181B5_v24
1 "Kharif only"
2 "Rabi only"
3 "Both"
4 "None";
cap la val S181B5_v24 S181B5_v24;

 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_V1_bk1_5.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";


***************************************************************;
* SCHEDULE 18.1 - Level 2- Block 6 -  Visit 1                  ;
***************************************************************;

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	psn_itm_No	  28-30
str	S181B6_v1	  31
str	S181B6_v3	  32
str	S181B6_v4	  33-34
str	S181B6_v5	  35
str	S181B6_v6	  36
str	S181B6_v7	  37
str	S181B6_v8	  38-39
str	S181B6_v9	  40
str	S181B6_v10	  41-42
str	S181B6_v11	  43
str	sector	      121
str	stratum	      122-123
str	subsample	  124
str	subround	  125
str	update_code	  126
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V1`i'.TXT";

keep if level=="02";
gen hhid= block_No+substratum+hhno;
destring,replace;
format hhid %14.0f;

label var	hhid 	      "Household ID";
label var	round	      "Round Schedule";
label var	sample	      "Sample";
label var	visit 	      "Visit No.";
label var	statereg      "State Region";
label var   state         "State";
label var	flot	      "Flot No.";
label var	block_No	  "Village/Block Srl.No.(fsu)";
label var	substratum	  "Sub-stratum No.";
label var	hhno	      "Sample HH No.";
label var	level 	      "Level No.";
label var	holding_No	  "Operational holding No.";
label var	psn_itm_No	  "Srl.No.of member";
label var	S181B6_v1	  "Type code/Srl.no. of lessee";
label var	S181B6_v3	  "Relation to head";
label var	S181B6_v4	  "Age (years)";
label var	S181B6_v5	  "Sex";
label var	S181B6_v6	  "General education";
label var	S181B6_v7	  "If 'not' literate, whether can read";
label var	S181B6_v8	  "Usual Activity - Principal Status (code)";
label var	S181B6_v9	  "Usual Activity - Principal Industry Section";
label var	S181B6_v10	  "Subsidiary (gainful) Status (code)";
label var	S181B6_v11	  "Subsidiary (gainful) Industry section";
label var	sector	      "Sector";
label var	stratum	      "Stratum";
label var	subsample	  "Sub-sample";
label var	subround	  "Sub-round";
label var	update_code	  "Update code";
label var	MLT_subsample "Multiplier-I for sub-sample estimates";
label var	MLT_combined  "Multiplier-II for combined estimates";

foreach x in sample state sector {;
la val `x' `x';
};

cap la def S181B6_v3
1"Self"
2"Spouse of head"
3"Married child"
4"Spouse of married child"
5"Unmarried child"
6"Grand child"
7"Father/mother/father-in-law/mother-in-law"
8"Brother/sister/brother-in-law/sister-in-law/other relatives"
9"Servant/employee/paying guest/other non-relatives";
cap la val S181B6_v3  S181B6_v3;

cap la def S181B6_v6
1"Not literate"
2"Literate but below primary"
3"Primary and above but below secondary"
4"Secondary/higher secondary"
5"Graduate and above";
cap la val S181B6_v6  S181B6_v6;

foreach x in S181B6_v8 S181B6_v10 {;
cap la def `x'
11"Worked in household enterprise (self employed)"
21"Worked as helper in household enterprise"
31"Worked as regular-salaried /wage employed"
41"Worked as casual wage labor in public works"
51"In other types of work"
81"Did not work but was seeking and/or available for work"
91"Attended educational institution"
92"Attended domestic duties"
93"Attended domestic duties & also engaged in free collection of goods,sewing, tailoring, weaving etc for household use"
94"Rentiers, pensioners, remittance receipts etc"
95"Not able to work due to disability"
96"Beggars, prostitute"
97"Others";
cap la val `x' `x';
};

foreach x in S181B6_v9 S181B6_v11 {;
cap la def `x'
0 "Agriculture, hunting, forest & fishing"
1 "Mining & Quarrying"
2 "Manufacturing"
3 "Manufacturing"
4 "Electricity, gas and water"
5 "Construction"
6 "Wholesale and retail trade and restaurants and hotels"
7 "Transport, storage and communication"
8 "Financing, insurance, real estate and business services"
9 "Community, social and personal services";
cap la val `x' `x';
};  

cap la def S181B6_v3
1 "Self"	                                                                                                      
2 "Spouse of head"
3 "Married child"
4 "Spouse of married child"
5 "Unmarried child"
6 "Grand child"
7 "Father/mother/father-in-law/Mother-in-law"
8 "Brother/sister/brother-in-law/Sister-in-law/other relatives"
9 "Servant/employee/paying guest/Other non-relative";
cap la val S181B6_v3 S181B6_v3;

cap la def S181B6_v5
1 "Male" 2 "Female";
cap la val S181B6_v5 S181B6_v5;

cap la def S181B6_v6
1 "Not literate"
2 "Literate but below primary"
3 "Primary and above but below secondary"
4 "Secondary/higher secondary"
5 "Graduate and above";
cap la val S181B6_v6 S181B6_v6;

cap la def S181B6_v7
1 "Yes" 2 "No";
cap la val S181B6_v7 S181B6_v7;

foreach x in S181B6_v8 S181B6_v10 {;
cap la def `x'
11 "Worked in household enterprise (self employed)"
21 "Worked as helper in household enterprise"
31 "Worked as regular-salaried/wage employee"
41 "Worked as casual wage labour in public works"
51 "Worked as casual labour in other types of work"
81 "Did not work but was seeking and/ or available for work"
91 "Attended educational institution"
92 "Attended domestic duties"
93 "Attended domestic duties,also free collection of goods for household use"
94 "Renters,pensioners,remittance recipients etc"
95 "Not able  to work due to disability"
96 "Beggars, prostitutes"
97 "Others";
cap la val `x' `x';
};


save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

isid hhid psn_itm_No;
order psn_itm_No hhid state;
sort hhid state;
compress ;

saveold "$pathout\NSS48_Sch181_V1_bk6.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";

***************************************************************;
* SCHEDULE 18.1 - Level 3 - Block 7 -  Visit 1                 ;
***************************************************************;

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	S181B7_v1	  28-30
str	S181B7_v2	  31
str	S181B7_v3	  32
str	S181B7_v4	  33
str	S181B7_v5	  34-38
str	S181B7_v6	  39-41
str	S181B7_v7	  42-46
str	S181B7_v8	  47-51
str	S181B7_v9	  52-56
str	S181B7_v10	  57-61
str	S181B7_v11	  62-66
str	S181B7_v12	  67-71
str	S181B7_v13	  72-76
str	S181B7_v14	  77
str	S181B7_v15	  78
str	S181B7_v17	  79-83
str	S181B7_v18	  84
str	S181B7_v19	  85
str	S181B7_v16	  121-125
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V1`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;

label var	hhid 	      "Household ID	";
label var	round	      "Round Schedule";
label var	sample	      "Sample";
label var	visit 	      "Visit No.";
label var	statereg      "State Region";
label var   state         "State";
label var	flot	      "Flot No.";
label var	block_No	  "Village/Block Srl.No.(fsu)";
label var	substratum	  "Sub-stratum No.";
label var	hhno	      "Sample HH No.";
label var	level	      "Level No.";
label var	holding_No	  "Operational holding No.";
label var	S181B7_v1	  "Srl.No.of plot";
label var	S181B7_v2	  "Record No./Srl.No.of lessee";
label var	S181B7_v3	  "location code";
label var	S181B7_v4	  "Area quoted from document/memory";
label var	S181B7_v5	  "Geographical area of plot";
label var	S181B7_v6	  "Percentage of area owned by hh.";
label var	S181B7_v7	  "Actual area owned by hh.";
label var	S181B7_v8	  "Seasonal crop area:- With irrigation facility (0.00 acres)";
label var	S181B7_v9	  "Seasonal crop area:- Without irrigation facility (0.00 acres)";
label var	S181B7_v10	  "Orchard plantation etc (0.00 acres)";
label var	S181B7_v11	  "Put for Non-agrl. use:-Water bodies (0.00 acres)";
label var	S181B7_v12	  "Other Non-agrl. Use (0.00 acres)";
label var	S181B7_v13	  "Others";
label var	S181B7_v14	  "Whether any part of land leased out";
label var	S181B7_v15	  "If yes, No. of lessee hh";
label var	S181B7_v17	  "Area leased out (0.00 acres)";
label var	S181B7_v18	  "Type of lessee (code)";
label var	S181B7_v19	  "Terms of lease(code)";
label var	S181B7_v16	  "ID";
label var	MLT_subsample "Multiplier-I for sub-sample estimates";
label var	MLT_combined  "Multiplier-II for combined estimates	";


foreach x in sample state sector {;
la val `x' `x';
};

cap la def S181B7_v3
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 S181B7_v3 S181B7_v3;

cap la def S181B7_v4
1 "From document"
2 "From memory";
cap la val S181B7_v4 S181B7_v4;

cap la def S181B7_v14
1"Yes" 2"No";
cap la val S181B7_v14 S181B7_v14;

cap la def S181B7_v18
1"Urban: Cultivating hhld within sample town. Rural: Cultivating hhld within sample village"
2"Urban:Cultivating hhld within other urban areas. Rural:Cultivating hhld within other rural areas."
3"Urban:Other urban households.Rural: Other rural households"
4"Urban:Urban households. Rural:Rural Households"
9"Others";
cap la val S181B7_v18 S181B7_v18;

cap la def S181B7_v19
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 usufractuary mortgage"
7"From relatives under no specified terms"
9"Under no terms";
cap la val S181B7_v19 S181B7_v19;

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_V1_bk7.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";


***************************************************************;
* SCHEDULE 18.1 - Level 4 - Block 8 -   Visit 1           ;
***************************************************************;

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	S181B8_v1	  28-30
str	S181B8_v2	  31
str	S181B8_v3	  32
str	S181B8_v4	  33
str	S181B8_v5	  34-38
str	S181B8_v6	  39-41
str	S181B8_v7	  42-46
str	S181B8_v8	  47-51
str	S181B8_v9	  52-56
str	S181B8_v10	  57-61
str	S181B8_v11	  62-66
str	S181B8_v12	  67-71
str	S181B8_v13	  72-76
str	S181B8_v14	  77
str	S181B8_v15	  78
str	S181B8_v16	  79
str	S181B8_v17	  80
str	update_code	  121-125
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V1`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;

label var	hhid 	      "Household ID";
label var	round	      "Round Schedule";
label var	sample	      "Sample";
label var	visit 	      "Visit No.";
label var	statereg      "State Region";
label var   state         "State";
label var	flot	      "Flot No.";
label var	block_No	  "Village/Block Srl.No.(fsu)";
label var	substratum	  "Sub-stratum No.";
label var	hhno	      "Sample HH No.";
label var	level 	      "Level No.";
label var	holding_No	  "Operational holding No.";
label var	S181B8_v1	  "Srl. no. of plot";
label var	S181B8_v2	  "Record No./Srl.No.of lessee";
label var	S181B8_v3	  "Location code";
label var	S181B8_v4	  "Area quoted from memory/ document";
label var	S181B8_v5	  "Geographical area of plot";
label var	S181B8_v6	  "% of area leased-in /otherwise possessed";
label var	S181B8_v7	  "Actual area leased-in/otherwise possessed";
label var	S181B8_v8	  "Area by type of land - Seasonal crop area with irrigation facility (0.00 acres)	";
label var	S181B8_v9	  "Seasonal crop area:- Without irrigation facility	";
label var	S181B8_v10	  "Orchard plantation etc.";
label var	S181B8_v11	  "Non-agrl. use:-Water bodies";
label var	S181B8_v12	  "Other non-agrl. use";
label var	S181B8_v13	  "Others";
label var	S181B8_v14	  "Type of posssession(code)";
label var	S181B8_v15	  "Duration of  posession (code)";
label var	S181B8_v16	  "If 1 or 2, Terms of lease (code)";
label var	S181B8_v17	  "Lessor type";
label var	update_code	  "Identification particulars";
label var	MLT_subsample "Multiplier-I for sub-sample estimates";
label var	MLT_combined  "Multiplier-II for combined estimates";


foreach x in sample state sector {;
la val `x' `x';
};

cap la def S181B8_v3
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 S181B8_v3 S181B8_v3;

cap la def S181B8_v4
1"Memory" 2"Document";
cap la val S181B8_v4 S181B8_v4;

cap la def S181B8_v14
1"Recorded lease"
2"Not recorded lease"
3"Otherwise possessed";
cap la val S181B8_v14 S181B8_v14;

cap la def S181B8_v15
1"Less than an agricultural season"
2"At least one agr season but less than one agr yr"
3"At least one agr yr, but less than two agr yrs"
4"At least two agr yrs but less than five agr yrs"
5"At least five agr yrs but less than twelve agr yrs"
6"Twelve agr yrs or more";
cap la val S181B8_v15 S181B8_v15;

cap la def S181B8_v16
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 usufractuary mortgage"
7"From relatives under no specified terms"
9"Under no terms";
cap la val S181B8_v16 S181B8_v16;

cap la def S181B8_v17
1"Urban: Cultivating hhld within sample town. Rural: Cultivating hhld within sample village"
2"Urban:Cultivating hhld within other urban areas. Rural:Cultivating hhld within other rural areas."
3"Urban:Other urban households.Rural: Other rural households"
4"Urban:Urban households. Rural:Rural Households"
9"Others";
cap la val S181B8_v17 S181B8_v17;


save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

isid hhid S181B8_v1 ;
order hhid state;
sort  hhid state;
compress ;

saveold "$pathout\NSS48_Sch181_V1_bk8.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";


***************************************************************;
* SCHEDULE 18.1 - Level 5 - Block 9 -  Visit 1                ;
***************************************************************;

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	S181B9_v1	  28-30
str	S181B9_v4	  31
str	S181B10_v3	  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\D170V1`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;

label var	hhid 	      "	Household ID";
label var	round	      "	Round Schedule";
label var	sample	      "	Sample";
label var	visit 	      "	Visit No.";
label var	statereg      "	State Region";
label var   state         " State";
label var	flot	      "	Flot No.";
label var	block_No	  "	Village/Block Srl.No.(fsu)";
label var	substratum	  "	Sub-stratum No.";
label var	hhno	      "	Sample HH No.";
label var	level 	      "	Level No.";
label var	holding_No	  "	Operational holding No.";
label var	S181B9_v1	  "	Srl.No.of plot";
label var	S181B9_v4	  "	Record No./Srl.No.of lessee";
label var	S181B10_v3	  "	If joint, no. of partners hh.";
label var	S181B9_v2	  "	As in block";
label var	S181B9_v3	  "	Srl.no of plot as in bl 7/8";
label var	S181B9_v5	  "	Location code";
label var	S181B9_v6	  "	Geographical area";
label var	S181B9_v7	  "	% of area operated";
label var	S181B9_v8	  "	Actual area operated (0.00 acres)";
label var	S181B9_v9	  "	Land operated - if owned, area leased  (0.00 acres)";
label var	S181B9_v10	  "	If leased in:- Whether lease is recorded";
label var	S181B9_v11	  "	If leased in:- Period of lease";
label var	S181B9_v12	  "	Lessor type";
label var	S181B9_v13	  "	Terms of lease";
label var	S181B9_v14	  "	Area (0.00 acres)";
label var	S181B9_v15	  "	Area of land otherwise possessed (0.00 acres)";
label var	S181B9_v16	  "	Area water-logged : With drainage facility  (0.00 acres)";
label var	S181B9_v17	  "	Without drainage facility";
label var	S181B9_v18	  "	Area by land use : Forest (0.00 acres)";
label var	S181B9_v19	  "	Net shown area unirrigated";
label var	S181B9_v20	  "	Irrigated area (0.00 acres)";
label var	S181B9_v21	  "	Irrigated (Source)";
label var	S181B9_v22	  "	Fallow during Kharif (0.00)";
label var	S181B9_v23	  "	Water bodies for pisciculture";
label var	S181B9_v24	  "	Other non-agrl. use	";
label var	S181B9_v25	  "	Others";
label var	S181B9_v26	  "	Whether any agrl. production carried out";
label var	S181B9_v27	  "	Whether possessed for major part of agrl. year 1991-92";
label var	MLT_subsample "	Multiplier-I for sub-sample estimates";
label var	MLT_combined  "	Multiplier-II for combined estimates";

foreach x in sample state sector {;
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 S181B10_v11
1"Less than an agricultural season"
2"At least one agr season but less than one agr yr"
3"At least one agr yr, but less than two agr yrs"
4"At least two agr yrs but less than five agr yrs"
5"At least five agr yrs but less than twelve agr yrs"
6"Twelve agr yrs or more";
cap la val S181B10_v11 S181B10_v11;

cap la def S181B9_v12
1"Urban: Cultivating hhld within sample town. Rural: Cultivating hhld within sample village"
2"Urban:Cultivating hhld within other urban areas. Rural:Cultivating hhld within other rural areas."
3"Urban:Other urban households.Rural: Other rural households"
4"Urban:Urban households. Rural:Rural Households"
9"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 usufractuary mortgage"
7"From relatives under no specified terms"
9"Under no terms";
cap la val S181B9_v13 S181B9_v13;

cap la def S181B9_v21
1"Canal"
2"Tank"
3"Tube well"
4"Well"
9"Others";
cap la val S181B9_v21 S181B9_v21;

foreach x in S181B9_v10 S181B9_v26 S181B9_v27 {;
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";

order hhid state sector;
sort hhid state;
compress ;

saveold "$pathout\NSS48_Sch181_V1_bk9.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";


***************************************************************;
* SCHEDULE 18.1 - Level 6 - Block 10  -  Visit 1                ;
***************************************************************;

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	plot_No 	  28-30
str	record_No	  31
str	S181B10_v2	  32
str	S181B10_v3	  33
str	S181B10_v4	  34
str	S181B10_v5	  35
str	S181B10_v6	  36
str	S181B10_v7	  37
str	S181B10_v8	  38
str	S181B10_v9	  39
str	S181B10_v10	  40
str	S181B10_v11	  41
str	S181B10_v12	  42
str	S181B10_v13	  43
str	S181B10_v14	  44
str	S181B10_v15	  45
str	S181B10_v16	  46-47
str	S181B10_v17	  48-50
str	S181B10_v18	  51-52
str	S181B10_v19	  53-54
str	S181B10_v20	  55-56
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V1`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;

label var	hhid 	      "Household ID";
label var	round	      "Round Schedule";
label var	sample	      "Sample";
label var	visit         "Visit No.";
label var	statereg	  "State Region";
label var   state         "State";
label var	flot	      "Flot No.";
label var	block_No	  "Village/Block Srl.No.(fsu)";
label var	substratum	  "Sub-stratum No.";
label var	hhno	      "Sample HH No.";
label var	level 	      "Level No.";
label var	S181B10_v1	  "Operational holding No.";
label var	plot_No  	  "Srl.No.of plot";
label var	record_No	  "Record No./Srl.No.of lessee";
label var	S181B10_v2	  "How operated";
label var	S181B10_v3	  "If jointly, no. of partner hh";
label var	S181B10_v4	  "Class of area operated";
label var	S181B10_v5	  "Type of holding";
label var	S181B10_v6	  "Maximum use of the holding";
label var	S181B10_v7	  "Whether activity carried on in the operational holding during kharif:Cultivation in kitchen garden";
label var	S181B10_v8	  "Livestock keeping";
label var	S181B10_v9	  "Poultry";
label var	S181B10_v10	  "Other agrl. Production in the homestead";
label var	S181B10_v11	  "Orchards";
label var	S181B10_v12	  "Plantations";
label var	S181B10_v13	  "Raising field crops";
label var	S181B10_v14	  "Pisiculture";
label var	S181B10_v15	  "Other agrl. production";
label var	S181B10_v16	  "No. of parcels in the the holding";
label var	S181B10_v17	  "Distance  of  farthest parcel from residence";
label var	S181B10_v18	  "No. of parcels in the cultivated area of holding";
label var	S181B10_v19	  "No.of permanent attached farm workers during the season against payment of wages";
label var	S181B10_v20	  "No.of permanent attached farm workers during the season against share of produce";
label var	MLT_subsample "Multiplier-I for sub-sample estimates";
label 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_V1_bk10.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";


***************************************************************;
* SCHEDULE 18.1 - Level 7 - Block 11 -  Visit 1            ;
***************************************************************;

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	S181B11_v1	  28-30
str	record_No	  31
str	S181B11_v3	  32-33
str	S181B11_v4	  34-35
str	S181B11_v5	  36-37
str	S181B11_v6	  38-39
str	S181B11_v7	  40-41
str	S181B11_v8	  42-43
str	S181B11_v9	  44-45
str	S181B11_v10	  46-47
str	S181B11_v11	  48-49
str	S181B11_v12	  50-51
str	S181B11_v13	  52-54
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V1`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;

label var	hhid 	      "Household ID";
label var	round	      "Round Schedule";
label var	sample	      "Sample";
label var	visit 	      "Visit No.";
label var	statereg      "State Region";
label var   state         "State";
label var	flot	      "Flot No.";
label var	block_No	  "Village/Block Srl.No.(fsu)";
label var	substratum	  "Sub-stratum No.";
label var	hhno	      "Sample HH No.";
label var	level	      "Level No.";
label var	holding_No	  "Operational holding No.";
label var	S181B11_v1	  "Srl.No.of bovine";
label var	record_No	  "Record No./Srl.No.of lessee";
label var	S181B11_v3	  "Adult males - For breeding only  (Nos.)";
label var	S181B11_v4	  "Adult males - For work only  (Nos.)	";
label var	S181B11_v5	  "Adult males - For breeding & work both  (Nos.)";
label var	S181B11_v6	  "Adult males -Others  (Nos.)";
label var	S181B11_v7	  "Adult females not calved once (Nos.)";
label var	S181B11_v8	  "Adult females - In Milk (Nos.)";
label var	S181B11_v9	  "Adult females - Dry (Nos.)";
label var	S181B11_v10	  "Adult females - Others (Nos.)";
label var	S181B11_v11	  "Young Stock -Male (No.)";
label var	S181B11_v12	  "Young Stock -Females (No.)";
label var	S181B11_v13	  "Total";
label var	MLT_subsample "Multiplier-I for sub-sample estimates";
label var	MLT_combined  "Multiplier-II for combined estimates	";

foreach x in sample state sector {;
la val `x' `x';
};


save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

isid hhid S181B11_v1;
order hhid state sector;
sort hhid state block;
compress ;

saveold "$pathout\NSS48_Sch181_V1_bk11.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";

***************************************************************;
* SCHEDULE 18.1 - Level 8 - Block 12 - Visit 1          ;
***************************************************************;

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	S181B12_v1	  32-34
str	S181B12_v2	  35-37
str	S181B12_v3	  38-40
str	S181B12_v4	  41-43
str	S181B12_v5	  44-45
str	S181B12_v6	  46-47
str	S181B12_v7	  48-49
str	S181B12_v8	  50-52
str	S181B12_v9	  53-55
str	S181B12_v10   56-58
str	S181B12_v11	  59-62
str	S181B12_v12	  63-66
str	S181B12_v13	  67-70
str	S181B12_v14	  71-74
str	S181B12_v15	  75-78
str	S181B12_v16   79-82
str	S181B12_v17	  83-86
str	S181B12_v18	  87-91
str	MLT_subsample 151-160
str	MLT_combined  161-170

using "$pathin\D170V1`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;

label var	hhid 	      "Household ID";
label var	round	      "Round Schedule";
label var	sample	      "Sample";
label var	visit 	      "Visit No.";
label var	statereg      "State Region";
label var   state         "State";
label var	flot	      "Flot No.";
label var	block_No	  "Village/Block Srl.No.(fsu)";
label var	substratum	  "Sub-stratum No.";
label var	hhno	      "Sample HH No.";
label var	level	      "Level No.";
label var	holding_No	  "Operational holding No.";
label var	plot_No	      "Item/person/plot no.";
label var	record_No	  "Record No./Srl.No.of lessee";
label var	S181B12_v1	  "Others large heads -Horses & ponies";
label var	S181B12_v2	  "Mules";
label var	S181B12_v3	  "Donkeys";
label var	S181B12_v4	  "Camels";
label var	S181B12_v5	  "Yaks";
label var	S181B12_v6	  "Mithun";
label var	S181B12_v7	  "Elephants";
label var	S181B12_v8	  "Bovine -Sheep (nos.)";
label var	S181B12_v9	  "Goat (nos.)";
label var	S181B12_v10	  "Pigs (nos.)";
label var	S181B12_v11	  "Hens:- Deshi";
label var	S181B12_v12	  "Hens:-Improved";
label var	S181B12_v13   "Cocks:- Deshi";
label var	S181B12_v14	  "Cocks:-Improved";
label var	S181B12_v15	  "Chicken";
label var	S181B12_v16	  "Ducks";
label var	S181B12_v17	  "Other birds";
label var	S181B12_v18	  "Total";
label var	MLT_subsample "Multiplier-I for sub-sample estimates";
label var	MLT_combined  "Multiplier-II for combined estimates";

foreach x in sample state sector {;
la val `x' `x';
};

save "$pathout\p`i'.dta", replace;
	};

use "$pathout\pR.dta",clear;
append using "$pathout\pU.dta";

isid hhid ; 
order hhid state sector;
sort hhid state block;
compress ;

saveold "$pathout\NSS48_Sch181_V1_bk12.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";


***************************************************************;
* SCHEDULE 18.1 - Level 9 - Block 13 - Visit 1               ;
***************************************************************;

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	S181B12_v1_1   29-31
str	S181B12_v1_3   32-34
str	S181B12_v2_1   35-37
str	S181B12_v2_3   38-40
str	S181B12_v3_1   41-43
str	S181B12_v3_3   44-46
str	S181B12_v4_1   47-49
str	S181B12_v4_3   50-52
str	S181B12_v5_1   53-55
str	S181B12_v5_3   56-58
str	S181B12_v6_1   59-61
str	S181B12_v6_3   62-64
str	S181B12_v7_1   65-67
str	S181B12_v7_3   68-70
str	S181B12_v8_1   71-73
str	S181B12_v8_3   74-76
str	S181B12_v9_1   77-79
str	S181B12_v9_3   80-82
str	S181B12_v10_1  83-85
str	S181B12_v10_3  86-88
str	S181B12_v11_1  89-91
str	S181B12_v11_3  92-94
str	S181B12_v12_1  95-97
str	S181B12_v12_3  98-100
str	S181B12_v13_1  101-103
str	S181B12_v13_3  104-106
str	S181B12_v14_1  107-109
str	S181B12_v14_3  110-112
str	S181B12_v26	   113-114
str	MLT_subsample  151-160
str	MLT_combined   161-170

using "$pathin\D170V1`i'.TXT";

keep if level=="09";
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;

label var	hhid 	      "Household ID";
label var	round	      "Round Schedule";
label var	sample	      "Sample";
label var	visit 	      "Visit No.";
label var	statereg      "State Region";
label var   state         "State";
label var	flot	      "Flot No.";
label var	block_No	  "Village/Block Srl.No.(fsu)";
label var	substratum	  "Sub-stratum No.";
label var	hhno	      "Sample HH No.";
label var	level	      "Level No.";
label var	holding_No	  "Operational holding No.";
label var	S181B12_v1_1  "Item code";
label var	S181B12_v1_3  "No.owned";
label var	S181B12_v2_1  "Item code";
label var	S181B12_v2_3  "No. owned";
label var	S181B12_v3_1  "Item code";
label var	S181B12_v3_3  "No. owned";
label var	S181B12_v4_1  "Item code";
label var	S181B12_v4_3  "No. owned";
label var	S181B12_v5_1  "Item code";
label var	S181B12_v5_3  "No. owned";
label var	S181B12_v6_1  "Item code";
label var	S181B12_v6_3  "No. owned";
label var	S181B12_v7_1  "Item code";
label var	S181B12_v7_3  "No. owned";
label var	S181B12_v8_1  "Item code";
label var	S181B12_v8_3  "No. owned";
label var	S181B12_v9_1  "Item code";
label var	S181B12_v9_3  "No. owned";
label var	S181B12_v10_1 "Item code";
label var	S181B12_v10_3 "No. owned";
label var	S181B12_v11_1 "Item code";
label var	S181B12_v11_3 "No. owned";
label var	S181B12_v12_1 "Item code";
label var	S181B12_v12_3 "No. owned";
label var	S181B12_v13_1 "Item code";
label var	S181B12_v13_3 "No. owned";
label var	S181B12_v14_1 "Item code";
label var	S181B12_v14_3 "No. owned";
label var	S181B12_v26	  "No. of item reported";
label var	MLT_subsample "Multiplier-I for sub-sample estimates";
label var	MLT_combined  "Multiplier-II for combined estimates";

foreach x in sample state sector {;
la val `x' `x';
};


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_V1_bk13.dta", replace ;
erase "$pathout\pR.dta";
erase "$pathout\pU.dta";
