i have created variable DAYS from PERIOD_FROM and PERIOD_TO. i have data for year 2009 to 2014. all years data have survey of the month except year 2009. so what i actaully want is to merge that data finally of all years thats why i want a solution like below:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str8 HH_ID str10(PERIOD_FROM PERIOD_TO) str43 ITEM_NAME str4 ITEM_UNIT double(QTY_HOME_PROD QTY_PUR QTY_OT) byte(OT_CODE CODE_WHO) str16 CODE_WHO_OT double(PRICE_UNIT TOT_VAL) str30 REMARKS float DAYS "IMHB0216" "30/12/2009" "31/12/2009" "Wheat " "Kg " . . 1 2 1 " " 15 15 " " 1 "IAPA0082" "29/12/2009" "31/12/2009" "Rice " "Kg " . 4 . . . " " 20 80 " " 2 "IAPC0035" "28/12/2009" "31/12/2009" "Pearl/Finger millet " "Kg " . .5 . . . " " 10 5 " " 3 "IAPC0010" "27/12/2009" "31/12/2009" "Rice " "Kg " . 12 . . . " " 13 156 " " 4 "IAPA0328" "26/12/2009" "31/12/2009" "Sorghum " "Kg " . 1 . . . " " 25 25 " " 5 "IMHB0047" "25/12/2009" "31/12/2009" "Sorghum " "Kg " 8 . . . . " " 8 64 " " 6 "IMHB0211" "24/12/2009" "31/12/2009" "PDS Wheat " "Kg " . 4 . . . " " 5.5 22 " " 7 "IMHB0035" "23/12/2009" "31/12/2009" "PDS Rice " "Kg " . 1 . . . " " 10 10 " " 8 "IMHB0058" "22/12/2009" "31/12/2009" "Rice " "Kg " . 1 . . . " " 22 22 " " 9 "IAPA0309" "21/12/2009" "31/12/2009" "Sorghum " "Kg " . 5 . . . " " 25 125 " " 10 "IAPD0039" "20/12/2009" "31/12/2009" "Rice " "Kg " . 15 . . . " " 30 450 " " 11 "IMHC0059" "04/12/2009" "16/12/2009" "Sorghum " "Kg " . 2 . . . " " 8 16 " " 12 "IAPB0052" "18/12/2009" "31/12/2009" "Rice " "Kg " . 25 . . . " " 10 250 " " 13 "IMHA0056" "17/12/2009" "31/12/2009" "PDS Wheat " "Kg " . 2 . . . " " 5 10 " " 14 "IMHD0315" "16/12/2009" "31/12/2009" "Wheat " "Kg " . 12 . . . " " 15 180 " " 15 "IMHA0053" "15/12/2009" "31/12/2009" "PDS Rice " "Kg " . 10 . . . " " 6 60 " " 16 "IMHA0049" "14/12/2009" "31/12/2009" "Wheat " "Kg " 20 . . . . " " 14 280 " " 17 "IAPA0241" "13/12/2009" "31/12/2009" "Wheat " "Kg " . 1 . . . " " 22 22 " " 18 "IAPD0001" "12/12/2009" "31/12/2009" "Rice " "Kg " . 22 . . . " " 30 660 " " 19 "IMHC0215" "22/11/2009" "12/12/2009" "Sorghum " "Kg " 15 . . . . " " 8 120 " " 20 "IMHB0226" "05/12/2009" "26/12/2009" "PDS Rice " "Kg " . 3 . . . " " 10 30 " " 21 "IMHC0216" "13/11/2009" "05/12/2009" "Sorghum " "Kg " . 15 . . . " " 8 120 " " 22 "IMHD0290" "24/11/2009" "17/12/2009" "Rice " "Kg " . 2.5 . . . " " 20 50 " " 23 "IMHA0036" "21/11/2009" "15/12/2009" "PDS Rice " "Kg " . 10 . . . " " 6 60 " " 24 "IMHC0216" "06/12/2009" "31/12/2009" "Sorghum " "Kg " . 10 . . . " " 8 80 " " 25 "IMHB0032" "03/12/2009" "29/12/2009" "PDS Wheat " "Kg " . 20 . . . " " 5.5 110 " " 26 "IMHC0205" "01/02/2010" "28/02/2010" "PDS Rice " "Kg " . 5 . . . " " 4 20 " " 27 "IAPA0082" "30/11/2009" "28/12/2009" "Wheat " "Kg " . 1 . . . " " 20 20 " " 28 "IMHC0210" "01/04/2010" "30/04/2010" "PDS Rice " "Kg " . 4 . . . " " 7.5 30 " " 29 "IAPB0035" "01/05/2010" "31/05/2010" "PDS Rice " "Kg " . 16 . . . " " 2 32 " " 30 "IAPB0277" "02/11/2009" "03/12/2009" "PDS Rice " "Kg " . 12 . . . " " 2 24 " " 31 "IAPB0038" "04/11/2009" "06/12/2009" "Rice " "Kg " . 56 . . . " " 16 896 " " 32 "IAPB0299" "12/11/2009" "15/12/2009" "Rice " "Kg " . . 32 1 3 " " 28 896 " " 33 "IAPB0059" "27/10/2009" "30/11/2009" "PDS Rice " "Kg " . 25 . . . " " 2 50 " " 34 "IAPB0278" "29/10/2009" "03/12/2009" "Rice " "Kg " . 30 . . . " " 15 450 " " 35 "IMHD0275" "17/11/2009" "27/12/2009" "PDS Wheat " "Kg " . 10 . . . " " 5.5 55 " " 40 "IAPA0036" "01/02/2010" "19/03/2010" "Wheat " "Kg " . 1 . . . " " 24 24 " " 46 "IAPB0289" "02/11/2009" "19/12/2009" "Sorghum " "Kg " . 4 . . . " " 10 40 " " 47 "IMPA0050" "05/11/2009" "31/12/2009" "Wheat " "Kg " 35 . . . . " " 15 525 " " 56 "IKND0050" "01/01/2010" "28/02/2010" "PDS Rice " "Kg " . 24 . . . " " 3 72 " " 58 "IAPD0045" "01/01/2010" "31/03/2010" "Wheat " "Kg " . 3 . . . " " 20 60 " " 89 "IAPB0059" "01/07/2009" "26/10/2009" "PDS Rice " "Kg " . 32 . . . " " 2 64 " " 117 "IAPB0042" "01/07/2009" "27/10/2009" "PDS Rice " "Kg " . 90 . . . " " 2 180 " " 118 "IAPB0203" "01/07/2009" "28/10/2009" "Rice " "Kg " . 36 . . . " " 15 540 " " 119 "IAPB0036" "01/07/2009" "29/10/2009" "Wheat " "Kg " . 4 . . . " " 18 72 " " 120 "IAPB0047" "01/07/2009" "30/10/2009" "Rice " "Kg " . 60 . . . " " 28 1680 " " 121 "IAPB0257" "01/07/2009" "31/10/2009" "Sorghum " "Kg " . 10 . . . " " 10 100 " " 122 "IMHC0034" "01/07/2009" "01/11/2009" "Sorghum " "Kg " . 60 . . . " " 8 480 " " 123 "IAPA0303" "01/07/2009" "02/11/2009" "PDS Rice " "Kg " . 64 . . . " " 2 128 " " 124 "IAPC0054" "01/07/2009" "03/11/2009" "Pearl/Finger millet " "Kg " 25 . . . . " " 10 250 " " 125 "IAPC0051" "01/07/2009" "04/11/2009" "Rice " "Kg " . 180 . . . " " 30 5400 " " 126 "IAPA0305" "01/07/2009" "05/11/2009" "Rice " "Kg " 140 . . . . " " 20 2800 " " 127 "IAPB0276" "01/07/2009" "06/11/2009" "PDS Rice " "Kg " . 64 . . . " " 2 128 " " 128 "IAPC0040" "01/07/2009" "07/11/2009" "PDS Rice " "Kg " . 80 . . . " " 2 160 " " 129 "IAPA0202" "01/07/2009" "08/11/2009" "Sorghum " "Kg " . 20 . . . " " 18 360 " " 130 "IMHA0005" "01/07/2009" "09/11/2009" "PDS Wheat " "Kg " . 60 . . . " " 5 300 " " 131 "IAPD0002" "01/07/2009" "10/11/2009" "Wheat " "Kg " . 6 . . . " " 24 144 " " 132 "IAPA0055" "01/07/2009" "11/11/2009" "Rice " "Kg " 275 . . . . " " 20 5500 " " 133 "IMHA0261" "01/07/2009" "12/11/2009" "PDS Rice " "Kg " . 80 . . . " " 6 480 " " 134 "IMHA0208" "01/07/2009" "13/11/2009" "PDS Rice " "Kg " . 40 . . . " " 6 240 " " 135 "IMHB0219" "01/07/2009" "14/11/2009" "Sorghum " "Kg " . 50 . . . " " 8 400 " " 136 "IMHB0206" "01/07/2009" "15/11/2009" "PDS Rice " "Kg " . 40 . . . " " 6.5 260 " " 137 "IMHC0035" "01/07/2009" "16/11/2009" "Wheat " "Kg " . 25 . . . " " 12 300 " " 138 "IMHB0200" "01/07/2009" "17/11/2009" "Sorghum " "Kg " . 225 . . . " " 7.5 1687.5 " " 139 "IMHC0001" "01/07/2009" "18/11/2009" "PDS Rice " "Kg " . 50 . . . " " 4 200 " " 140 "IMHD0291" "01/07/2009" "19/11/2009" "PDS Wheat " "Kg " . 25 . . . " " 5.5 137.5 " " 141 "IAPA0308" "01/07/2009" "20/11/2009" "Wheat " "Kg " . 5 . . . " " 20 100 " " 142 "IMHC0223" "01/07/2009" "21/11/2009" "Rice " "Kg " . 18 . . . " " 14 252 " " 143 "IAPA0058" "01/07/2009" "22/11/2009" "Pearl/Finger millet " "Kg " . 4 . . . " " 18 72 " " 144 "IMHD0312" "01/07/2009" "23/11/2009" "Rice " "Kg " . 12 . . . " " 25 300 " " 145 "IAPA0323" "01/07/2009" "24/11/2009" "Rice " "Kg " 40 10 . . . " " 20 1000 " " 146 "IMHB0244" "01/07/2009" "25/11/2009" "Sorghum " "Kg " 60 . . . . " " 7.5 450 " " 147 "IAPD0042" "01/07/2009" "26/11/2009" "Wheat " "Kg " . 6 . . . " " 20 120 " " 148 "IAPD0057" "01/07/2009" "27/11/2009" "Wheat " "Kg " . 5 . . . " " 20 100 " " 149 "IMHC0211" "01/07/2009" "28/11/2009" "PDS Rice " "Kg " . 40 . . . " " 9 360 " " 150 "IAPC0035" "01/07/2009" "29/11/2009" "PDS Rice " "Kg " . 80 . . . " " 2 160 " " 151 "IMHC0218" "01/07/2009" "30/11/2009" "Sorghum " "Kg " . 40 . . . " " 8 320 " " 152 "IMHB0050" "01/07/2009" "01/12/2009" "Sorghum " "Kg " 200 . . . . " " 7.5 1500 " " 153 "IMHB0231" "01/07/2009" "02/12/2009" "Sorghum " "Kg " . . 25 2 1 " " 7.5 187.5 " " 154 "IMHB0239" "01/07/2009" "03/12/2009" "PDS Rice " "Kg " . 30 . . . " " 10 300 " " 155 "IMHD0002" "01/07/2009" "04/12/2009" "Wheat " "Kg " 50 . . . . " " 15 750 " " 156 "IMHB0033" "01/07/2009" "05/12/2009" "PDS Rice " "Kg " . 35 . . . " " 6.5 227.5 " " 157 "IKNB0038" "01/07/2009" "31/12/2009" "PDS Rice " "Kg " . 30 . . . " " 3 90 " " 183 "IAPD0048" "12/02/2009" "31/12/2009" "Rice " "Kg " . 15 . . . " " 32 480 " " 322 end
let for example for below observation DAYS are less than 31 so it is one month period over which data is collected:
Code:
clear input str8 HH_ID str10(PERIOD_FROM PERIOD_TO) str43 ITEM_NAME str4 ITEM_UNIT double(QTY_HOME_PROD QTY_PUR QTY_OT) byte(OT_CODE CODE_WHO) str16 CODE_WHO_OT double(PRICE_UNIT TOT_VAL) str30 REMARKS float(DAYS) "IMHB0216" "30/12/2009" "31/12/2009" "Wheat " "Kg " . . 1 2 1 " " 15 15 " " 1
Code:
clear input str8 HH_ID str10(SUR_MON_YR) str43 ITEM_NAME str4 ITEM_UNIT double(QTY_HOME_PROD QTY_PUR QTY_OT) byte(OT_CODE CODE_WHO) str16 CODE_WHO_OT double(PRICE_UNIT TOT_VAL) str30 REMARKS float( DAYS) "IMHB0216" "12/2009" "Wheat " "Kg " . . 1 2 1 " " 15 15 " " 1
now for another observation:
Code:
clear input str8 HH_ID str10(SUR_MON_YR) str43 ITEM_NAME str4 ITEM_UNIT double(QTY_HOME_PROD QTY_PUR QTY_OT) byte(OT_CODE CODE_WHO) str16 CODE_WHO_OT double(PRICE_UNIT TOT_VAL) str30 REMARKS float( DAYS) "IKNB0038" "01/07/2009" "31/12/2009" "PDS Rice " "Kg " . 30 . . . " " 3 90 " " 183
so the desired result are
Code:
clear input str8 HH_ID str10(SUR_MON_YR) str43 ITEM_NAME str4 ITEM_UNIT double(QTY_HOME_PROD QTY_PUR QTY_OT) byte(OT_CODE CODE_WHO) str16 CODE_WHO_OT double(PRICE_UNIT TOT_VAL) str30 REMARKS float( DAYS) "IKNB0038" "07/2009" "PDS Rice " "Kg " . 5 . . . " " 3 15 " " 183 "IKNB0038" "08/2009" "PDS Rice " "Kg " . 5 . . . " " 3 15 " " 183 "IKNB0038" "09/2009" "PDS Rice " "Kg " . 5 . . . " " 3 15 " " 183 "IKNB0038" "10/2009" "PDS Rice " "Kg " . 5 . . . " " 3 15" " 183 "IKNB0038" "11/2009" "PDS Rice " "Kg " . 5 . . . " " 3 15 " " 183 "IKNB0038" "12/2009" "PDS Rice " "Kg " . 5 . . . " " 3 15 " " 183
same for all other possible months.
please help me.
Thanks in advance
0 Response to generate survey of the month from period
Post a Comment