*this program is designed to summarize the credit status of each household set talk off close all select 2 use summary go top select 1 use credit go top do while .not. eof() store .f. to mprflag && true if loan is under positive reciprocity mhhnum=hhnum mvillage=village minvalue=0.00 && total recieved in commercial loans moutvalue=0.00 && total given out as commercial loans mnetin=0.00 && current net value of commercial loans received mnetout=0.00 && current net value of commercial loans given out minvaluep=0.00 && total recived in p.r. loans moutvaluep=0.00 && total given out as p.r. loans mnetinp=0.00 && current net value of p.r. loans received mnetoutp=0.00 && current net value of p.r. loans given out mnumin=0 && number of commercial loans received mnumout=0 && number of commercial loans given out mnuminp=0 && number of p.r. loans received mnumoutp=0 && number of p.r. loans given out *the following loops for each loan in a particular household, *checking the values to be entered and summing the net position on *loans paid and recieved (mnetout, mnetin) for commercial and non-commercial *(mnetoutp, mentinp) the total received in commercial loans (minvalue) and *non-commercial loans (minvaluep), and the total given as commercial loans *(moutvalue) and non-commercial loans (moutvaluep) do while hhnum=mhhnum mloanin=loan_in && flags for current loan- in or out mloanout=.not.mloanin loanvalue=0.00 &&keeps track of value of this loan across the 7 items tvalue=0.00 &&keeps the value of the current item clear *first we want to decide if the loan is based on positive reciprocity *or not, so display relationship and past deals @ 1,1 say 'decide if this loan should be included as an instance' @ 2,1 say 'of positive recirprocity:' @ 4,1 say 'relationship to other party: '+relation @ 6,1 say ' previous deals frequency value this month duration' @ 7,1 say deal1 @ 7,27 say frequency1 @ 7,36 say av_value1 @ 7,44 say thismonth1 @ 7,56 say duration1 @ 8,1 say deal2 @ 8,27 say frequency2 @ 8,36 say av_value2 @ 8,44 say thismonth2 @ 8,56 say duration2 @ 9,1 say deal3 @ 9,27 say frequency3 @ 9,36 say av_value3 @ 9,44 say thismonth3 @ 9,56 say duration3 @ 11,1 say 'Is this an instance of P.R.?' @ 11,30 get mprflag read clear * now start checking and summing the seven possible items if item1<>'money' @ 2,1 say 'Check for the proper value of:' @ 4,1 say item1 @ 5,1 say form1 @ 6,1 say quantity1 @ 7,1 say unit1 @ 8,1 say value1 @ 9,1 say date1 @ 9,10 say 'is this item in? '+in1 @ 11,1 get tvalue read *tvalue will be equal to the value of this component of the loan, and will *be negative if it is a payment to the household, as it represents a debit tvalue=iif(tvalue>0,tvalue,value1) tvalue=iif(in1='y',-tvalue,tvalue) else tvalue=iif(in1='y',-value1,value1) endif loanvalue=tvalue * next we add up the value of items received in loans in...we * subtract tvalue because it is negative. This is done for both * commercial loans and loans with positive recirprocity if mloanin.and.in1='y' if mprflag minvaluep=minvaluep-tvalue else minvalue=minvalue-tvalue endif endif * next we add up value of items given out in loans out if mloanout.and.in1='n' if mprflag moutvaluep=moutvaluep+tvalue else moutvalue=moutvalue+tvalue endif endif if item2<>' ' if item2<>'money' @ 2,1 say 'Check for the proper value of:' @ 4,1 say item2 @ 5,1 say form2 @ 6,1 say quantity2 @ 7,1 say unit2 @ 8,1 say value2 @ 9,1 say date2 @ 9,10 say 'is this item in? '+in2 @ 11,1 get tvalue read tvalue=iif(tvalue>0,tvalue,value2) tvalue=iif(in2='y',-tvalue,tvalue) else tvalue=iif(in2='y',-value2,value2) endif loanvalue=tvalue+loanvalue if mloanin.and.in2='y' if mprflag minvaluep=minvaluep-tvalue else minvalue=minvalue-tvalue endif endif if mloanout.and.in2='n' if mprflag moutvaluep=moutvaluep+tvalue else moutvalue=moutvalue+tvalue endif endif endif if item3<>' ' if item3<>'money' @ 2,1 say 'Check for the proper value of:' @ 4,1 say item3 @ 5,1 say form3 @ 6,1 say quantity3 @ 7,1 say unit3 @ 8,1 say value3 @ 9,1 say date3 @ 9,10 say 'is this item in? '+in3 @ 11,1 get tvalue read tvalue=iif(tvalue>0,tvalue,value3) tvalue=iif(in3='y',-tvalue,tvalue) else tvalue=iif(in3='y',-value3,value3) endif loanvalue=tvalue+loanvalue if mloanin.and.in3='y' if mprflag minvaluep=minvaluep-tvalue else minvalue=minvalue-tvalue endif endif if mloanout.and.in3='n' if mprflag moutvaluep=moutvaluep+tvalue else moutvalue=moutvalue+tvalue endif endif endif if item4<>' ' if item4<>'money' @ 2,1 say 'Check for the proper value of:' @ 4,1 say item4 @ 5,1 say form4 @ 6,1 say quantity4 @ 7,1 say unit4 @ 8,1 say value4 @ 9,1 say date4 @ 9,10 say 'is this item in? '+in4 @ 11,1 get tvalue read tvalue=iif(tvalue>0,tvalue,value4) tvalue=iif(in4='y',-tvalue,tvalue) else tvalue=iif(in4='y',-value4,value4) endif loanvalue=tvalue+loanvalue if mloanin.and.in4='y' if mprflag minvaluep=minvaluep-tvalue else minvalue=minvalue-tvalue endif endif if mloanout.and.in4='n' if mprflag moutvaluep=moutvaluep+tvalue else moutvalue=moutvalue+tvalue endif endif endif if item5<>' ' if item5<>'money' @ 2,1 say 'Check for the proper value of:' @ 4,1 say item5 @ 5,1 say form5 @ 6,1 say quantity5 @ 7,1 say unit5 @ 8,1 say value5 @ 9,1 say date5 @ 9,10 say 'is this item in? '+in5 @ 11,1 get tvalue read tvalue=iif(tvalue>0,tvalue,value5) tvalue=iif(in5='y',-tvalue,tvalue) else tvalue=iif(in5='y',-value5,value5) endif loanvalue=tvalue+loanvalue if mloanin.and.in5='y' if mprflag minvaluep=minvaluep-tvalue else minvalue=minvalue-tvalue endif endif if mloanout.and.in5='n' if mprflag moutvaluep=moutvaluep+tvalue else moutvalue=moutvalue+tvalue endif endif endif if item6<>' ' if item6<>'money' @ 2,1 say 'Check for the proper value of:' @ 4,1 say item6 @ 5,1 say form6 @ 6,1 say quantity6 @ 7,1 say unit6 @ 8,1 say value6 @ 9,1 say date6 @ 9,10 say 'is this item in? '+in6 @ 11,1 get tvalue read tvalue=iif(tvalue>0,tvalue,value6) tvalue=iif(in6='y',-tvalue,tvalue) else tvalue=iif(in6='y',-value6,value6) endif loanvalue=tvalue+loanvalue if mloanin.and.in6='y' if mprflag minvaluep=minvaluep-tvalue else minvalue=minvalue-tvalue endif endif if mloanout.and.in6='n' if mprflag moutvaluep=moutvaluep+tvalue else moutvalue=moutvalue+tvalue endif endif endif if item7<>' ' if item7<>'money' @ 2,1 say 'Check for the proper value of:' @ 4,1 say item7 @ 5,1 say form7 @ 6,1 say quantity7 @ 7,1 say unit7 @ 8,1 say value7 @ 9,1 say date7 @ 9,10 say 'is this item in? '+in7 @ 11,1 get tvalue read tvalue=iif(tvalue>0,tvalue,value7) tvalue=iif(in7='y',-tvalue,tvalue) else tvalue=iif(in7='y',-value7,value7) endif loanvalue=tvalue+loanvalue if mloanin.and.in7='y' if mprflag minvaluep=minvaluep-tvalue else minvalue=minvalue-tvalue endif endif if mloanout.and.in7='n' if mprflag moutvaluep=moutvaluep+tvalue else moutvalue=moutvalue+tvalue endif endif endif if mloanin if mprflag mnetinp=mnetinp+loanvalue mnuminp=mnuminp+1 else mnetin=mnetin+loanvalue mnumin=mnumin+1 endif else if mprflag mnetoutp=mnetoutp+loanvalue mnumoutp=mnumoutp+1 else mnetout=mnetout+loanvalue mnumout=mnumout+1 endif endif skip enddo *now we have completed with the household, so check the findings *and write them to the new database clear @ 2,1 say mvillage @ 2,10 say 'household number' @ 2,27 say mhhnum @ 3,1 say 'the summary position of this houshold is:' @ 4,1 say 'net positions for commercial loans:' @ 5,1 say 'for loans in for loans out' @ 6,1 say mnetin @ 6,21 say mnetout @8,1 say 'totals transferred for commercial loans:' @9,1 say 'for loans in for loans out' @10,1 say minvalue @10,21 say moutvalue @11,1 say 'number of commercial loans in:' @11,32 say ltrim(str(mnumin))+' and '+ltrim(str(mnumout))+ ' out' @13,1 say 'net positions for loans with positive reciprocity:' @14,1 say 'for loans in ' @14,15 say ltrim(str(mnetinp))+' and for loans out '+ltrim(str(mnetoutp)) @15,1 say 'totals transferred for loans with positive reciprocity:' @16,1 say 'for loans in ' @16,14 say ltrim(str(minvaluep))+' and for loans out '+ltrim(str(moutvaluep)) @17,1 say 'there were ' @17,12 say ltrim(str(mnuminp))+' pr in and '+ltrim(str(mnumoutp))+' out' select summary locate for village=mvillage .and.hhnum=mhhnum wait replace netin with mnetin replace netout with mnetout replace invalue with minvalue replace outvalue with moutvalue replace netinp with mnetinp replace netoutp with mnetoutp replace invaluep with minvaluep replace outvaluep with moutvaluep replace numin with mnumin replace numout with mnumout replace numinp with mnuminp replace numoutp with mnumoutp select credit *now loop back up for a new household enddo