*********************************************************************************

**

*********************************************************************************

** *Author: Ryan Stapler, Abt Associates Inc. *Created: 2/5/2010; *Updated: 5/02/2014; *Purpose: This a SAS program which calculates nonuse benefits using a benefit transfer approach based on Zhao et al. (2013). The approach estimates nonuse benefits in the North Alantic and Mid-Atlantic regions based on changes in the abundance of winter flounder under the final rule and other options considered. Resulting benefits estimates are reported in 1,000s of dollars.

*********************************************************************************

**

********************************************************************************* **;

*SPECIFY INPUT AND OUTPUT FILES****************************************************; *file locations;

%let d=s; *(C or H or S drive); %let facloc=&d.:\Projects\Tyche\WA 4-05 (316b)\Benefits Estimation\Final_05.02.14\;

%let mainloc=&facloc.Existing_facilities\BT\; %let inloc=&mainloc.Inputs\; %let outloc=&mainloc.Outputs\; *input files;

%let fac_input=Facility_Inputs_and_Weights_01.25.14.xls; %let in_BT=Nonuse_Benefit_Transfer_Inputs_01.26.14.xls; %let input2=IE_outputs_25JAN14_adjusted_for_state_regs.xls; *output files;

%let output=BT_BenOutputs_&sysdate..xls; %let tables=BT_BenTables_&sysdate..xls; %let SumTables=BT_BenTablesSum_&sysdate..xls; %let printout=&outloc.BT Ben Tables &sysdate..rtf; %let printout3=&outloc.BT Ben Tables &sysdate..csv;

*SET DISCOUNTING AND COMPLIANCE ASSUMPTIONS****************************************;

%let d0=2013; *(d0 is the base year for discounting); %let t0=2014; *(t0 is promulgation year -i.e., 1st year with costs); %let yrsc=51; *(yrsc is the annualization period); %let ie_year=2017; *(all years prior to ie_year include installation of

impingement tech only. this is no longer relevant within the code, set to 2017 to deactivate for model runs (the 1st compliance year is 2018); %let af_3=(0.03*(1.03**(51-1)))/((1.03**51)-1); *(af_3 is the adjustment
factor to convert the net present value of benefits to annualized benefits using a 3 percent discount rate);

%let af_7=(0.07*(1.07**(51-1)))/((1.07**51)-1); *(af_7 is the adjustment
factor to convert the net present value of benefits to annualized benefits using a 7 percent discount rate);

*SET ANALYZED SPECIES**************************************************************;

%let species_1="winter.flounder"; *(species_1 is the species being used
benefit transfer in the North Atlantic and Mid-Atlantic regions);

%let species_1a="Winter Flounder"; *(species_1a is the name of the analyzed species as it will be presented in final tables);

*DEFINE MACROS FOR IMPORTING AND EXPORTING DATA************************************; *macro to import from excel; Page 1%macro import(infile,insheet,out);

PROC IMPORT OUT= WORK.&out

DATAFILE= "&infile"

DBMS=EXCEL REPLACE; SHEET="&insheet.$";

GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN; %mend; *macro to export to excel; %macro export(datafile,outfile,sheet);
PROC EXPORT DATA= &datafile

OUTFILE= &outfile DBMS=EXCEL replace; SHEET=&sheet;

RUN; %mend;

*DEFINE MACROS FOR IMPORTING AND EXPORTING DATA************************************; *import facility data; %import(&facloc.&fac_input,facility_data,facility_data); *import household data; %import(&inloc.&in_BT,HH_data_reg,HH_1); *import population change data; %import(&inloc.&in_BT,abun_change,abun_change); *import CPI data; %import(&facloc.&fac_input,CPI,CPI); *import I&E data; %import(&facloc.&input2,BNB_IE,ie); *import impingement data; %import(&facloc.&input2,BNB_IMP,i_only); *import entrainment data; %import(&facloc.&input2,BNB_ENT,ent_only); *import the worksheet with the ccr.fraction data; %import(&facloc.&input2,REDUCTIONS_DETAIL,reductions_detail);

*REORGANIZE THE DATA IN ORDER TO CALCULATE FRACTION OF IM&E REDUCTIONS ASSOCIATED

WITH INSTALLATION OF IMPINGMENTS TECHNOLOGY****************************************; *NOTE: this step is no longer relevant with ie_year set to 2017; DATA reductions_detail;

SET reductions_detail; if region="" then delete; DROP regional_reduction_imp regional_reduction_ent ccr_fraction_ent benefit_value_regional_imp;

RUN; PROC SORT data=reductions_detail;

By option_name region;

RUN; Data i_only_1;

set i_only; DO imp_benefit_value_regional=benefit_value_regional;

END; IF species_econ~="zz.all.species" then delete; IF metric~="ae1" then delete; if comrec_type~="all.types" then delete; IF region="zz.allregions" then delete; DROP lossmode baseline_value baseline_value_regional benefit_value benefit_value_regional regional_reduction ccr_fraction;

RUN; PROC SORT data=i_only_1;

By option_name region value_basis species_econ metric comrec_type;

RUN; Data ent_only_1;

set ent_only; Page 2DO ent_benefit_value_regional=benefit_value_regional;

END; IF species_econ~="zz.all.species" then delete; IF metric~="ae1" then delete; if comrec_type~="all.types" then delete; IF region="zz.allregions" then delete; DROP lossmode baseline_value baseline_value_regional benefit_value benefit_value_regional regional_reduction ccr_fraction;

RUN; PROC SORT data=ent_only_1;

by option_name region value_basis species_econ metric comrec_type;

RUN; Data ie_rd1;

set ie; DO ie_benefit_value_regional=benefit_value_regional;

END; IF species_econ~="zz.all.species" then delete; IF metric~="ae1" then delete; if comrec_type~="all.types" then delete; IF region="zz.allregions" then delete; DROP regional_reduction ccr_fraction; if region="zz.allregions" then delete;

RUN; PROC SORT data=ie_rd1;

by option_name region value_basis species_econ metric comrec_type;

RUN; DATA ie_rd2;

merge ie_rd1 i_only_1 ent_only_1; by option_name region value_basis species_econ metric comrec_type;

RUN; Data ie_rd3;

merge ie_rd2 reductions_detail; by option_name region; IF ent_benefit_value_regional="." then do ent_benefit_value_regional=0;

END; IF imp_benefit_value_regional="." then do imp_benefit_value_regional=0;

END; imp_frac_imp=(1-ccr_fraction_imp); IF ie_benefit_value_regional~=0 then do impingement_fraction=((imp_frac_imp*imp_benefit_value_regional)/ie_benefit_value_ regional);

END; IF ie_benefit_value_regional=0 then do impingement_fraction="";

END; DROP ie_benefit_value_regional imp_benefit_value_regional ent_benefit_value_regional ccr_fraction_imp imp_frac_imp value_basis species_econ lossmode metric comrec_type baseline_value baseline_value_regional benefit_value benefit_value_regional;

RUN; Proc Sort data=ie out=ie;

by option_name region;

RUN; PROC Sort data=ie_rd3 out=ie_rd3;

by option_name region;

RUN; Data ie;merge ie ie_rd3;

by option_name region;

RUN;
*EDIT REGION NAMES AND SET CPI BASE YEAR*******************************************; DATA facility_data; Set facility_data; IF Region="CN" or Region ="CS" or Region ="HI" then reg="CAL"; IF Region="INL" then reg="INL"; IF Region="GL" then reg="GL"; IF Region="MA" then reg="MA"; IF Region="NA" then reg="NA"; IF Region="SA" then reg="SA"; Page 3IF Region="Mex" then reg="Mex";

IF Region="VI" then reg="VI"; IF Region="PNW" then reg="PNW";

RUN; PROC Sort data=abun_change out=abun_change;

by reg;

RUN; data cpi_1 (keep=CPI);

set cpi;if year=2008;

run;

*GENERATE ANNUAL WTP VALUES********************************************************; *reports total for the NORTHEAST (North Atlantic + Mid-Atlantic); Data reg_compile;

Merge HH_1 abun_change; by reg; IF _N_ = 1 then set cpi_1; array tmn(4) NE_baseline NE_tmn1 NE_tmn2 NE_tmn3; array WTPhh(4) WTPhh_baseline WTPhh_tmn1 WTPhh_tmn2 WTPhh_tmn3; array WTPreg(4) WTPreg_baseline WTPreg_tmn1 WTPreg_tmn2 WTPreg_tmn3; do i=1 to 4; *WTPhh(i) is the household WTP per year for the baseline percentage changesand the change under each option;

WTPhh(i)=tmn(i)*WTPper*cpi; *WTPreg(i) is the product of household WTP per and the the total number
of households in each region. Regional WTP is expressed in 1,000s of dollars;WTPreg(i)=WTPhh(i)*numHH/1000;

END; DROP baseline tmn1 tmn2 tmn3 i cpi; if reg="" then delete;

RUN;
*APPLY COMPLIANCE SCHEDULE AND DISCOUNT********************************************; *Trim the IM&E input data set and limit to A1E for the analyzed species; *The purpose of the following two data steps is to manipulate the data so the compliance schedule can be properly applied, especially considering the impingement fraction; *note that the impingement fraction is not longer relevant within the model code; data ie;set ie;

if species_econ~="winter.flounder" then delete; if metric~="ae1" then delete; if comrec_type~="all.types" then delete; if region="zz.allregions" then delete;

RUN; *sum Northeast IM&E (North Atlantic plus Mid-Atlantic); Proc sql;

create table ie_2 as select option_name, region, species_econ, lossmode, metric,

comrec_type, baseline_value_regional, benefit_value_regional, impingement_fraction, sum(baseline_value_regional) as baseline_sum, sum(benefit_value_regional) as benefit_sum From ie group by option_name,species_econ; Quit; Data ie_3;

Set ie_2; IF species_econ~="winter.flounder" then delete; Page 4baseline_frac=baseline_value_regional/baseline_sum; benefit_frac=benefit_value_regional/benefit_sum; IF option_name="option.tmn1" then option="tmn1"; IF option_name="option.tmn2" then option="tmn2"; IF option_name="option.tmn3" then option="tmn3"; DROP option_name; reg=region; DROP region;

RUN; *Import facility id map; %import(&facloc.&fac_input,IDMAP,f1); *Import facility weights; %import(&facloc.&fac_input,ID_AND_WEIGHT,ID_AND_WEIGHT); *Import flow data; %import(&facloc.&fac_input,flowdata,f3); *Import compliance years; %import(&facloc.&fac_input,complianceyear,cydata); %macro cyr; cydata.tmn1 as cyr_base, cydata.tmn1 as cyr_tmn1, cydata.tmn2 as cyr_tmn2, cydata.tmn3 as cyr_tmn3 %mend; proc sql;

create table f4 as select

id.plntcode, w.id as facility, w.ps_wgt as Weighting_Factor from f1 as id right join ID_AND_WEIGHT as w on id.surveyid=w.id; quit; *Drop double-counted plants; proc sort data=f4 out=f5; by plntcode; run; data f6;set f5; by plntcode; if (not first.plntcode | not last.plntcode) and Weighting_Factor=0 then delete;

run; *join flow and weight data; proc sql;

create table f7 as select

f6.*, f3.Benefits_Region,f3.AverageFlow from f6 full join f3 on f6.plntcode=f3.EIA_Code where f3.EIA_Code~=.; quit; *recode region variable; data f8 (keep=region AverageFlow Weighting_Factor PLNTCODE facility);

set f7;format region $14.;

if Benefits_Region="CN" | Benefits_Region="CS" | Benefits_Region="CAL" | Benefits_Region="HI" then delete;

else if Benefits_Region="GL" then delete; else if Benefits_Region="INL" then delete; else if Benefits_Region="MA" then region="Mid-Atlantic"; else if Benefits_Region="Mex" then delete; else if Benefits_Region="NA" then region="North Atlantic"; else if Benefits_Region="SA" then delete; else if Benefits_Region="VI" then delete; else if Benefits_Region="PNW" then delete;

run; *combine and format data with average flow, region, wgt, and compliance year; proc sql;

create table s2a as select

f8.plntcode,f8.AverageFlow as avgflow,f8.Region,f8.Weighting_Factor as newweight,

cydata.base_newtech as base_newtech, cydata.tmn1_newtech as tmn1_newtech, cydata.tmn2_newtech as tmn2_newtech, cydata.tmn3_newtech as tmn3_newtech, Page 5%cyr from f8 full join cydata on cydata.id=f8.facility; quit;

RUN; DATA s2a;

SET s2a; if region ="Inland" | region="California" | region="South Atlantic" | region="South Atlantic" | region="Great Lakes" | region="Gulf of Mexico" then delete;if cyr_base="." then delete;

if PLNTCODE="." then delete;

RUN;

*This macro calculates benefits schedule for impingement only facilities based on the specificaiton of ie_year; %macro step5schedule(opt,cyr,opt_short); data s3; *s3 contains plntcodes weights and compliance years along with the flow

arrays (flow arrays are equal to AIF) and includes the biological fraction as well.
These are multiplied to get the biological schedule.;

set s2a;where region~="Virgin Islands";

array flowy_(60) flowy_1-flowy_60; array bio(60) bio_1-bio_60; array bschd(60) bschd_1-bschd_60;

do i=1 to 60;

if "&opt"="baseline" then do;

flowy_(i)=avgflow;

if region="Inland" | region="Great Lakes" | region="Gulf of Mexico" then do; *benefits begin in first year for these regions;
*this assumes no biological lag; if i=1 then bio(i)=1; if i=2 then bio(i)=1; if i=3 then bio(i)=1; if i=4 then bio(i)=1; if i=5 then bio(i)=1; if i=6 then bio(i)=1;
if i>6 and i<=46 then bio(i)=1; if i=47 then bio(i)=.83; if i=48 then bio(i)=.67; if i=49 then bio(i)=.5; if i=50 then bio(i)=.33; if i=51 then bio(i)=.17; if i>51 then bio(i)=0; end; else do; *benefits also begin in the first year for these regions; if i=1 then bio(i)=1; if i=2 then bio(i)=1; if i=3 then bio(i)=1; if i=4 then bio(i)=1; if i=5 then bio(i)=1; if i=6 then bio(i)=1; if i=7 then bio(i)=1;
if i>7 and i<=46 then bio(i)=1; if i=47 then bio(i)=.83; if i=48 then bio(i)=.67; if i=49 then bio(i)=.5; if i=50 then bio(i)=.33; if i=51 then bio(i)=.17; if i>51 then bio(i)=0; end; Page 6end;

else do; if &cyr.>=&ie_year. then delete; if region="Inland" | region="Great Lakes" | region="Gulf of Mexico" then do; *benefits begin in first year for these regions; x=i-&cyr.+&t0; *e.g., if i=1 and cyr = 2011 and first year of rule is 2011 then x=1 in 2011;
if x<=0 then flowy_(i)=0; *x=1 in first year of compliance;
else flowy_(i)=avgflow*&opt_short._newtech; if _n_=1 then put "Not BASELINE";

if x<=0 then bio(i)=0;
else if x=1 then bio(i)=1;
else if x=2 then bio(i)=1;
else if x=3 then bio(i)=1;
else if x=4 then bio(i)=1;
else if x=5 then bio(i)=1;
else if x=6 then bio(i)=1;
else if x=7 then bio(i)=1;
else if x=8 then bio(i)=1;
else if x=9 then bio(i)=1;
else if x>=9 and i<=46 then bio(i)=1;
else if i=47 then bio(i)=.83;
else if i=48 then bio(i)=.67;
else if i=49 then bio(i)=.5;
else if i=50 then bio(i)=.33;
else if i=51 then bio(i)=0.17;
else if i>51 then bio(i)=0; end; else do;
*benefits also begin in first year for these regions; x=i-&cyr.+&t0; *e.g., if i=1 and cyr = 2011 and first year of rule is 2011 then x=1 in 2012;
if x<0 then flowy_(i)=0;*x=1 in second year of compliance;
else flowy_(i)=avgflow*&opt_short._newtech; if _n_=1 then put "Not BASELINE";

if x<=0 then bio(i)=0;
else if x=1 then bio(i)=1; Page 7else if x=2

then bio(i)=1;
else if x=3 then bio(i)=1;
else if x=4 then bio(i)=1;
else if x=5 then bio(i)=1;
else if x=6 then bio(i)=1;
else if x=7 then bio(i)=1;
else if x=8 then bio(i)=1;
else if x=9 then bio(i)=1;
else if x=10 then bio(i)=1;
else if x>=10 and i<=46 then bio(i)=1;
else if i=47 then bio(i)=.83;
else if i=48 then bio(i)=.67;
else if i=49 then bio(i)=.5;
else if i=50 then bio(i)=.33;
else if i=51 then bio(i)=0.17;
else if i>51 then bio(i)=0; end; end;

bschd(i)=(flowy_(i)*bio(i)); end; format reg $30.;

if region="California" then reg="calif"; else if region="Great Lakes" then reg="greatlakes"; else if region="Gulf of Mexico" then reg="gulfmexico"; else if region="Inland" then reg="inland"; else if region="Mid-Atlantic" then reg="midatlantic"; else if region="North Atlantic" then reg="northatlantic"; else if region="South Atlantic" then reg="southatlantic";

run;

*calculate total average flow by region; proc sql;

create table s5 as select

s3.*, sum(avgflow*newweight*&opt_short._newtech) as totalavgflow /*group flag*/

from s3 group by region; quit;

*generate flow and benefits schedule variables for each facility as percentages relative to total regional average flow; data s6 (drop=bio_1-bio_60 flowy_1-flowy_60);

set s5; array flowy_(60) flowy_1-flowy_60; Page 8array bschd(60) bschd_1-bschd_60; do i=1 to 60; IF totalavgflow~=0 then flowy_(i)=newweight*flowy_(i)/totalavgflow; IF totalavgflow=0 then flowy_(i)=0; IF totalavgflow~=0 then bschd(i)=newweight*bschd(i)/totalavgflow; IF totalavgflow=0 then bschd(i)=0; end;

run;

*sort data by region; proc sort data=s6 out=s7; by region; run; *generate benefits schedule variable for region, e.g., 1 = full benefits, .5 = 50% of full benefits; data s8_&opt (keep=option region reg rbschd_1-rbschd_60);

retain option region reg rbschd_1-rbschd_60;

set ; by region;

option="&opt"; array bschd(60) bschd_1-bschd_60; array rbschd(60) rbschd_1-rbschd_60;

do i=1 to 60;

if first.region then rbschd(i)=bschd(i);

else rbschd(i)+bschd(i); end; if last.region;

run; %mend; *This step generates the benefits schedule for facilities intalling impingment technology as specified using ie_year; %macro step6schedule(opt,cyr,opt_short); data s4;set s2a;where region~="Virgin Islands"; array flowy_(60) flowy_1-flowy_60; array bio(60) bio_1-bio_60; array bschd(60) bschd_1-bschd_60;

do i=1 to 60;

if "&opt"="baseline" then do;

flowy_(i)=avgflow; if region="Inland" | region="Great Lakes" | region="Gulf of Mexico" then do;
if i=1 then bio(i)=1;*benefits begin in first year for these regions; if i=2 then bio(i)=1; if i=3 then bio(i)=1; if i=4 then bio(i)=1; if i=5 then bio(i)=1; if i=6 then bio(i)=1;
if i>6 and i<=46 then bio(i)=1; if i=47 then bio(i)=.83; if i=48 then bio(i)=.67; if i=49 then bio(i)=.5; if i=50 then bio(i)=.33; if i=51 then bio(i)=.17; if i>51 then bio(i)=0; end; else do;
if i=1 then bio(i)=1;*benefits also begin in the first for these regions; if i=2 then bio(i)=1; if i=3 then bio(i)=1; if i=4 then bio(i)=1; if i=5 then bio(i)=1; if i=6 then bio(i)=1; if i=7 then bio(i)=1; Page 9if i>7 and i<=46 then

bio(i)=1; if i=47 then bio(i)=.83; if i=48 then bio(i)=.67; if i=49 then bio(i)=.5; if i=50 then bio(i)=.33; if i=51 then bio(i)=.17; if i>51 then bio(i)=0; end; end;

else do; if &cyr.<&ie_year. then delete; if region="Inland" | region="Great Lakes" | region="Gulf of Mexico" then do; *benefits begin in first year for these regions; x=i-&cyr.+&t0; *e.g., if i=1 and cyr = 2011 and first year of rule is 2011 then x=1 in 2011;
if x<=0 then flowy_(i)=0; *x=1 in first year of compliance;
else flowy_(i)=avgflow*&opt_short._newtech; if _n_=1 then put "Not BASELINE";

if x<=0 then bio(i)=0;
else if x=1 then bio(i)=1;
else if x=2 then bio(i)=1;
else if x=3 then bio(i)=1;
else if x=4 then bio(i)=1;
else if x=5 then bio(i)=1;
else if x=6 then bio(i)=1;
else if x=7 then bio(i)=1;
else if x=8 then bio(i)=1;
else if x=9 then bio(i)=1;
else if x>=9 and i<=46 then bio(i)=1;
else if i=47 then bio(i)=.83;
else if i=48 then bio(i)=.67;
else if i=49 then bio(i)=.5;
else if i=50 then bio(i)=.33;
else if i=51 then bio(i)=0.17;
else if i>51 then bio(i)=0; end; else do;
*benefits also begin in first year for these regions; x=i-&cyr.+&t0; *e.g., if i=1 and cyr = 2011 and first year of rule is 2011 then x=1 in 2012;
if x<0 then flowy_(i)=0;*x=1 in second year of compliance; Page 10else flowy_(i)=avgflow*&opt_short._newtech; if _n_=1 then put "Not BASELINE";

if x<=0 then bio(i)=0;
else if x=1 then bio(i)=1;
else if x=2 then bio(i)=1;
else if x=3 then bio(i)=1;
else if x=4 then bio(i)=1;
else if x=5 then bio(i)=1;
else if x=6 then bio(i)=1;
else if x=7 then bio(i)=1;
else if x=8 then bio(i)=1;
else if x=9 then bio(i)=1;
else if x=10 then bio(i)=1;
else if x>=10 and i<=46 then bio(i)=1;
else if i=47 then bio(i)=.83;
else if i=48 then bio(i)=.67;
else if i=49 then bio(i)=.5;
else if i=50 then bio(i)=.33;
else if i=51 then bio(i)=0.17;
else if i>51 then bio(i)=0; end; end; bschd(i)=(flowy_(i)*bio(i)); end; format reg $30.;

if region="California" then reg="calif"; else if region="Great Lakes" then reg="greatlakes"; else if region="Gulf of Mexico" then reg="gulfmexico"; else if region="Inland" then reg="inland"; else if region="Mid-Atlantic" then reg="midatlantic"; else if region="North Atlantic" then reg="northatlantic"; else if region="South Atlantic" then reg="southatlantic";

run;

*calculate total average flow by region; proc sql;

create table s5 as select

s4.*, sum(avgflow*newweight*&opt_short._newtech) as totalavgflow /*group flag*/ Page 11from s4 group by region;

quit;

*generate flow and benefits schedule variables for each facility as percentages relative to total regional average flow; data s6 (drop=bio_1-bio_60 flowy_1-flowy_60);

set s5; array flowy_(60) flowy_1-flowy_60;

array bschd(60) bschd_1-bschd_60;

do i=1 to 60;

IF totalavgflow~=0 then flowy_(i)=newweight*flowy_(i)/totalavgflow; IF totalavgflow=0 then flowy_(i)=0; IF totalavgflow~=0 then bschd(i)=newweight*bschd(i)/totalavgflow; IF totalavgflow=0 then bschd(i)=0; end;

run;

*sort data by region; proc sort data=s6 out=s25; by region; run; *generate benefits schedule variable for region, e.g., 1 = full benefits, .5 = 50% of full benefits; data s9_&opt (keep=option region reg rbschd_1-rbschd_60);

retain option region reg rbschd_1-rbschd_60; set s25;by region;

option="&opt"; array bschd(60) bschd_1-bschd_60; array rbschd(60) rbschd_1-rbschd_60;

do i=1 to 60;

if first.region then rbschd(i)=bschd(i);

else rbschd(i)+bschd(i); end; if last.region;

run; %mend; *Generate dataset of benefits schedule by option; %macro optionmac00;

%step5schedule(baseline,cyr_base,base); %step5schedule(tmn1,cyr_tmn1,tmn1); %step5schedule(tmn2,cyr_tmn2,tmn2); %step5schedule(tmn3,cyr_tmn3,tmn3); %mend; %macro optionmac11;

%step6schedule(baseline,cyr_base,base); %step6schedule(tmn1,cyr_tmn1,tmn1); %step6schedule(tmn2,cyr_tmn2,tmn2); %step6schedule(tmn3,cyr_tmn3,tmn3); %mend; %optionmac00; %optionmac11; *step5data contains the benefits schedules for all options for impingement only tech as specified by ie_year; data Step5data;

length option $50.0; set s8_baseline s8_tmn1 s8_tmn2 s8_tmn3; IF region="" THEN DELETE; DROP region; array rbschd_(60) rbschd_1-rbschd_60; do i=1 to 60; IF option="" then rbschd_(i)=0;

END;

run; proc sort data=step5data out=step5data_1;

by reg;

RUN; *step20data contains the benefits schedules for all options for entrainment tech as specified by ie_year; Page 12data Step20data; length option $50.0; set s9_baseline s9_tmn1 s9_tmn2 s9_tmn3; IF region="" THEN DELETE; DROP region; array rbschd_(60) rbschd_1-rbschd_60; array sbschd_(60) sbschd_1-sbschd_60; Do i=1 to 60; sbschd_(i)=rbschd_(i); DROP rbschd_1-rbschd_60;

END;

run; proc sort data=step20data out=step20data_1;

by reg;

RUN; *comp_calcs contains the seperate benefit schedules for all tech (step5data and step20data); data comp_calcs;

merge step5data_1 step20data_1; by reg option;

run; Proc sort data=comp_calcs out=comp_calcs;

by reg option;

Run; *ie_imp brings in the impingement fraction which needs to be applied to the comp_calcs sheet; Data ie_imp;

LENGTH option $20; SET ie (KEEP = option_name region metric comrec_type species_econ impingement_fraction);

If option_name="option.tmn1" then option="tmn1"; else if option_name="option.tmn2" then option="tmn2"; else if option_name="option.tmn3" then option="tmn3"; if species_econ~="winter.flounder" then delete; if region="zz.allregions" then delete; if metric~="ae1" then delete; if comrec_type~="all.types" then delete; drop option_name; reg=region; drop region; drop species_econ; drop metric; drop comrec_type;

RUN; Proc sort data=ie_imp out=ie_imp;

by reg option;

Run; *comp_imp merges benefits schedules with the impingement fraction; data comp_imp;

merge ie_imp comp_calcs; by reg option; if option="baseline" then impingement_fraction=0;

run; *comp_calcs_1 calculates the final benefit schedu; data comp_calcs_1;

set comp_imp; array rbschd_(60) rbschd_1-rbschd_60; array sbschd_(60) sbschd_1-sbschd_60; array fschd_(60) fschd_1-fschd_60; Do i=1 to 60; IF rbschd_(i)="." then rbschd_(i)=0; IF sbschd_(i)="." then sbschd_(i)=0;

fschd_(i)=impingement_fraction*rbschd_(i)+(1-impingement_fraction)*sbschd_(i);

max_fschd=round(max(of fschd_1-fschd_60),.000000000000001);*included to account for rounding error; End;

Run; *data checks; Page 13data comp_calcs_1; set comp_calcs_1; if max_fschd >1 then put _n_ "error flag 1 - fschd is greater than 1 " max_fschd;

if max_fschd <1 then put _n_ "error flag 2 - fschd is less than 1 " max_fschd;

RUN; *comp_calcs_2 contains the final compliance schedule for each option, the final biological schedules is listed vertically; DATA comp_calcs_2;

SET comp_calcs_1; Drop rbschd_1-rbschd_60; Drop sbschd_1-sbschd_60; Drop impingement_fraction; Drop i max_fschd;

RUN; *CALCULATIONS FOR REPOWERINGS*************************************************; *NOTE: No longer relevant, all set to 1; %import(&facloc.&input2,rep_adj,rep_adj); %import(&facloc.&fac_input,rpschd,rpschd); Proc sort data=rep_adj out=rep_adj;

by option;

RUN; Proc sort data=rpschd out=rpschd;

by option;

RUN; Data repow;

merge rep_adj rpschd; by option; adj=1/rp_adj; drop rp_adj;

RUN; Data repow_1;

set repow; array rpschd_(60) rpschd_1-rpschd_60; array rpschd_adj_(60) rpschd_adj_1-rpschd_adj_60; do i=1 to 60; rpschd_adj_(i)=rpschd_(i)*(1-adj); if rpschd_(i)=0 then rpschd_adj_(i)=0; end; drop rp_adj rpschd_1-rpschd_60 i; if lossmode="imp" then delete; if lossmode="ent" then delete; if region="zz.allregions" | region="calif" | region="southatlantic" | region="greatlakes" | region="gulfmexico" | region="inland" then delete;

if option= "baseline_0" | option="tmn1_0" | option="tmn2_0" | option="tmn3_0" then delete;

reg=region; drop region lossmode;

RUN; Proc Sort data=repow_1 out=repow_1;

by option reg;

RUN; Proc Sort data=comp_calcs_2 out=comp_calcs_2;

by option reg;

RUN; Data comp_calcs_2;

merge repow_1 comp_calcs_2; by option reg;

RUN; Data comp_calcs_2;

set comp_calcs_2; array fschd_(60) fschd_1-fschd_60; array rpschd_adj_(60) rpschd_adj_1-rpschd_adj_60; array fschd_adj_(60) fschd_adj_1-fschd_adj_60; do i = 1 to 60; fschd_adj_(i)=fschd_(i)*adj + rpschd_adj_(i); fschd_(i) = fschd_adj_(i);

END; Page 14drop i rpschd_adj_1-rpschd_adj_60 fschd_adj_1-fschd_adj_60 adj;

RUN; *end of repowering calculations;

PROC SORT data=ie_3 out=ie_3;

by reg;

RUN; *make changes to ie_3 to delete extraneous variables; Data ie_3;

LENGTH option $20; Set ie_3; DROP lossmode metric comrec_type baseline_value_regional benefit_value_regional impingement_fraction baseline_sum benefit_sum;

DROP lossmode metric comrec_type baseline_value_regional benefit_value_regional baseline_sum benefit_sum;

RUN; *generate baseline option for inclusion in the ie data set; DATA ie_baseline;

Set ie_3; IF option~="tmn1" then delete; benefit_frac=baseline_frac; option="baseline";

RUN; *merge the baseline option back with the rest of the ie data set; PROC SORT data=ie_baseline out=ie_baseline;

by option species_econ reg;

RUN; PROC SORT data=ie_3 out=ie_3;

by option species_econ reg;

RUN; DATA ie_all;

MERGE ie_baseline ie_3; by option species_econ reg; DROP baseline_frac;

RUN; *comp_calcs_2 contains the final benefits shedule for the mid-atlantic and north atlantic regions. these need to be combined for the Northeast (North Atlantic & Mid-Atlantic); PROC SORT data=comp_calcs_2 out=comp_calcs_2;

by option reg;

RUN;

PROC SORT data=ie_all out=ie_all;

by option reg species_econ;

RUN; *comp_calcs_4 contains each option and the final benefits schedule; DATA comp_calcs_4;

LENGTH option $20; Merge ie_all comp_calcs_2; by option reg; DROP baseline_frac;

RUN; DATA comp_calcs_5;

Set comp_calcs_4; IF reg="northatlantic" then delete; array ma_schd_(60) ma_schd_1-ma_schd_60; array fschd_(60) fschd_1-fschd_60; Do i=1 to 60; ma_schd_(i)=fschd_(i)*benefit_frac;

END; DROP fschd_1-fschd_60 benefit_frac reg i;

RUN; DATA comp_calcs_6;

Set comp_calcs_4; IF reg="midatlantic" then delete; array na_schd_(60) na_schd_1-na_schd_60; array fschd_(60) fschd_1-fschd_60; Do i=1 to 60; na_schd_(i)=fschd_(i)*benefit_frac;

END; Page 15DROP fschd_1-fschd_60 benefit_frac reg i;

RUN; PROC SORT data=comp_calcs_5 out=comp_calcs_5;

by option species_econ;

RUN; PROC SORT data=comp_calcs_6 out=comp_calcs_6;

by option species_econ;

RUN; *comp_calcs_7 merges the adjusted schedules for the Mid-Atlantic and North Atlantic regions and calculates a weighted northeast schedule (ne_schd); Data comp_calcs_7;

Merge comp_calcs_5 comp_calcs_6; by option species_econ; array ma_schd_(60) ma_schd_1-ma_schd_60; array na_schd_(60) na_schd_1-na_schd_60; array ne_schd_(60) ne_schd_1-ne_schd_60; Do i=1 to 60; IF na_schd_(i)="." then na_schd_(i)=0; ne_schd_(i)=ma_schd_(i) + na_schd_(i);

END;
RUN; *This step modifies the reg_compile dataset so it can be merged together with the final compliance schedule; DATA Reg_compile_1;

Set reg_compile; DROP tmn1 tmn2 tmn3 baseline;

DROP WTPper; DROP WTPhh_tmn1 WTPhh_tmn2 WTPhh_tmn3 WTPhh_baseline;

RUN; *reg_compile_2 lists analyzed species along with the reg benefits under each option; DATA reg_compile_2;

Set reg_compile_1; array WTPreg_(4) WTPreg_tmn1 WTPreg_tmn2 WTPreg_tmn3 WTPreg_baseline; array tmn(4) tmn1 tmn2 tmn3 baseline; do i=1 to 4; tmn(i)=WTPreg_(i);

END; DROP WTPreg_tmn1 WTPreg_tmn2 WTPreg_tmn3 WTPreg_baseline NE_baseline NE_tmn1 NE_tmn2 NE_tmn3;

DROP regHH; DROP i;

RUN; PROC sort data=reg_compile_2 out=reg_compile_2;

by reg species_econ;

RUN; PROC Transpose data=reg_compile_2 out=reg_compile_3;

By reg species_econ;

RUN; DATA reg_compile_3;

SET reg_compile_3 (rename=(_NAME_=option COl1=WTPreg));

RUN; PROC SORT data=reg_compile_3 out=reg_compile_3;

by option species_econ reg;

RUN; Data comp_calcs_8;

SET comp_calcs_7; DROP ma_schd_1-ma_schd_60 na_schd_1-na_schd_60 i;

RUN;

PROC SORT data=comp_calcs_8 out=comp_calcs_8;

by option species_econ;

RUN; *merge together the annual regional WTP values and the weighted Northeast compliance schedule; DATA reg_compile_4;

merge reg_compile_3 comp_calcs_8; by option species_econ; Page 16RUN;

*implement all discounting and annualization calcs; DATA reg_compile_5;

Set reg_compile_4; array yr_(60) yr_1-yr_60; array ne_schd_(60) ne_schd_1-ne_schd_60; array df3_(60) df3_1-df3_60; array df7_(60) df7_1-df7_60; array WTP0_(60) WTP0_1-WTP0_60; array WTP3_(60) WTP3_1-WTP3_60; array WTP7_(60) WTP7_1-WTP7_60; do i=1 to 60; yr_(i)=i; df3_(i)=1/(1.03**(i-1+(&t0.-&d0.))); df7_(i)=1/(1.07**(i-1+(&t0.-&d0.))); WTP0_(i)=WTPreg*ne_schd_(i); WTP3_(i)=WTPreg*ne_schd_(i)*df3_(i); WTP7_(i)=WTPreg*ne_schd_(i)*df7_(i);

END; WTP_NPV_3=sum(of WTP3_1-WTP3_60); WTP_NPV_7=sum(of WTP7_1-WTP7_60); Ann_WTP_3=WTP_NPV_3*&af_3.; Ann_WTP_7=WTP_NPV_7*&af_7.;

RUN; Data discounting_out; set reg_compile_5; if reg~="northeast" then delete; if _LABEL_="numHH" then delete; drop _LABEL_ species_econ ne_schd_1-ne_schd_60 yr_1-yr_60 df3_1-df3_60 df7_1-df7_60 i WTP_NPV_3 WTP_NPV_7 Ann_WTP_3 Ann_WTP_7;

RUN; Data reg_compile_6;

Set reg_compile_5 (Keep = reg species_econ option WTPreg Ann_WTP_3 Ann_WTP_7);

if option ="numHH" then delete; if reg ="northeast" then delete;

RUN; Data IE_breakdown; set I_only ent_only; if species_econ~="winter.flounder" then delete; if metric~="ae1" then delete; if region~="zz.allregions" then delete; if comrec_type~="all.types" then delete; drop metric comrec_type region value_basis; if lossmode="imp" then baseline_value_imp=baseline_value_regional; if lossmode="ent" then baseline_value_ent=baseline_value_regional; if baseline_value_imp="." then baseline_value_imp=0; if baseline_value_ent="." then baseline_value_ent=0; drop benefit_value_regional; if option_name~="option.tmn1" then delete; option_name="baseline"; drop lossmode;

RUN; proc sql; create table ie_breakdown as select "baseline" as option, sum(baseline_value_imp) as baseline_value_imp, sum(baseline_value_ent) as baseline_value_ent from ie_breakdown; quit; Data ie_breakdown; set ie_breakdown; imp_perc=baseline_value_imp/(baseline_value_imp+baseline_value_ent); ent_perc=baseline_value_ent/(baseline_value_imp+baseline_value_ent); drop baseline_value_imp baseline_value_ent;

RUN; Data reg_compile_6x; merge reg_compile_6 ie_breakdown; by option; Page 17if option="baseline" then WTPreg_imp=imp_perc*WTPreg;

if option="baseline" then WTPreg_ent=ent_perc*WTPreg; drop imp_perc ent_perc;

RUN; *EXPORT RESULTS*********************************************************; %export(reg_compile_6x,"&outloc.&output",Results_summary); %export(discounting_out,"&outloc.&output", Discounting_out);

Page 18