Good evening,
as a stata beginner I run into a problem preparing my data set.
I have to calculate the average of the spreads out of 4 columns which are sometimes the 3 digit numbers but also sometimes 3 digits and 1 decimal place. Therefore I would like to know how I can exclude the "L+" at the beginning but also the "/ x%" where applicable. Additionally sometimes there is no data point and therefore the average should not include them. Furthermore sometimes the column just shows a range "L+150-200" in which case I would need the average as well.
My goal is to have in each column just the spread value, f.ex. "325", and then I calculate the average.
Thanks in advance
These are the columns I am struggling with:
as a stata beginner I run into a problem preparing my data set.
I have to calculate the average of the spreads out of 4 columns which are sometimes the 3 digit numbers but also sometimes 3 digits and 1 decimal place. Therefore I would like to know how I can exclude the "L+" at the beginning but also the "/ x%" where applicable. Additionally sometimes there is no data point and therefore the average should not include them. Furthermore sometimes the column just shows a range "L+150-200" in which case I would need the average as well.
My goal is to have in each column just the spread value, f.ex. "325", and then I calculate the average.
Thanks in advance
These are the columns I am struggling with:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str19 RCPricing str18 TLAPricing str19 TLBPricing str13 TLCPricing str10 TLDPricing "L+325" "L+325" "L+350 / 4%" "" "" "L+325" "" "L+325" "" "" "L+350" "" "L+350 / 3.25%" "" "" "L+200" "" "L+375 / 3%" "" "" "L+250" "L+250" "L+275 / 3%" "" "" "L+200" "" "L+425 / 3.25%" "" "" "L+350" "" "L+400 / 3.5%" "" "" "" "" "L+250" "" "" "L+225" "" "L+500 / 3.25%" "" "" "L+175" "" "L+500 / 3.5%" "" "" "L+400" "" "L+400 / 3.25%" "" "" "L+275" "L+250" "L+275 / 3%" "" "" "" "" "L+500 / 3.5%" "" "" "" "" "L+800 / 3.5%" "" "" "L+500" "" "L+500 / 3%" "" "" "L+400" "" "L+400 / 3.75%" "" "" "" "" "L+375 / 3.5%" "" "" "L+400" "L+425" "L+450 / 3%" "" "" "L+325" "L+325" "L+350 / 3%" "" "" "L+150" "" "L+250" "" "" "L+450" "" "L+450 / 3.5%" "" "" "" "" "L+325" "" "" "" "" "" "L+225 / 3%" "" "L+200" "" "L+750 / 3.25%" "" "" "L+375" "L+375" "L+400 / 3%" "" "" "L+400" "L+400" "L+450 / 3%" "" "" "" "" "L+350 / 3%" "" "" "" "" "L+450 / 3.25%" "" "" "" "" "L+250" "" "" "L+250" "L+250" "L+250" "" "" "L+625" "L+625 / 3.5%" "" "" "" "L+275" "" "L+275 / 3%" "" "" "" "" "L+525 / 3.25%" "" "" "" "L+250" "L+325" "" "" "" "" "L+300 / 3%" "" "" "L+525" "" "L+525 / 3.25%" "" "" "L+425" "" "L+425 / 3%" "" "" "L+225" "L+275" "L+325" "" "" "L+500" "" "L+500 / 3%" "" "" "L+375" "" "L+450 / 3%" "" "" "L+450" "" "L+475 / 3%" "" "" "L+325" "L+325" "L+350 / 3%" "" "" "L+250" "L+250" "L+300 / 3%" "" "" "L+500" "" "L+500 / 3%" "" "" "" "" "L+350 / 3.25%" "" "" "L+450" "" "L+450 / 3.25%" "" "" "L+400" "" "L+400 / 3%" "" "" "L+400" "" "L+400 / 3.25%" "" "" "L+400" "L+400" "L+600 / 3.25%" "" "" "L+650" "L+650" "L+650 / 3.5%" "" "" "" "" "L+600 / 3.5%" "" "" "L+600" "" "L+600 / 3%" "" "" "L+400" "L+400" "L+450 / 2%" "" "" "L+350" "" "L+350 / 3%" "" "" "" "" "" "L+325 / 2%" "" "L+350" "" "L+440 / 3.25%" "" "" "L+400" "" "L+400 / 2.5%" "" "" "" "" "L+650 / 3%" "" "" "L+450" "" "L+600 / 3%" "" "" "" "" "L+450 / 3%" "" "" "" "" "L+750 / 3%" "" "" "L+450" "" "L+500 / 2%" "" "" "L+350" "" "L+375 / 2%" "" "" "" "" "L+350" "" "" "" "" "" "" "L+350 / 2%" "" "" "" "" "" "NA" "" "L+675 / 2%" "" "" "" "" "L+600 / 2.5%" "" "" "" "" "" "" "" "L+600" "" "L+700 / 2%" "" "" "" "" "L+500 / 2%" "" "" "L+350" "" "L+350 / 2%" "" "" "L+550" "" "L+550 / 3%" "" "" "" "" "" "" "" "L+400 / 2%" "" "L+400 / 2%" "" "" "L+425" "" "L+425 / 2.25%" "" "" "L+825" "" "L+825 / 3%" "" "" "" "" "L+987.5 / 2.5%" "" "" "L+325" "" "L+325 / 2.5%" "" "" "L+450" "" "L+475 / 2.25%" "" "" "" "" "L+550 / 2%" "" "" "" "" "L+1000 / 3.5%" "" "" "L+500" "" "L+500 / 2%" "" "" "" "" "L+750 / 2%" "" "" "L+500" "L+425 / 2%" "" "" "" "" "" "L+475 / 2%" "" "" "" "" "L+375 / 2%" "" "" "L+425 / 2%" "" "L+425 / 2%" "" "" "L+400" "" "L+400 / 2%" "" "" "L+350" "L+350" "L+375 / 2%" "" "" "L+325" "L+325" "L+325 / 2%" "" "" "L+450" "" "L+450 / 2%" "" "" "NA" "" "L+350 / 2%" "" "" "NA" "" "L+550 / 2%" "" "" "L+375" "" "L+400 / 2%" "" "" "" "" "L+450 / 2%" "" "" "L+350" "" "L+350 / 2.25%" "" "" "" "" "" "" "" "L+350" "" "L+350 / 2%" "" "" "L+500" "" "L+600 / 2.25%" "" "" end
Comment