/* GENERATE GRAPHICS */ goptions reset=all xpixels=&xpixels ypixels=&ypixels display transparency device=webframe gsfname=out gsfmode=replace; /* RELATIVE PRICES N_GOOD_? */ %macro plot_rpgs(rpg=,one=,two=,pdrill=); data clean_anno_p&two.p&one anno_p&two.p&one; length function style color $8; retain xsys '5' ysys '2' when 'a' style 'solid'; %let gap_start=1; %let gap_width=1; %let gap_range=%eval(&&g&one._max - &&g&one._selected_threshold ); %if &gap_range > 10 %then %do; %let gap_start=%eval(&gap_range/2); %let gap_width=%eval(&gap_range/4); %end; %put "G&one GAP=&gap_range,&gap_start,&gap_width"; /* top & bottom block separated */ %if &gap_range > 4 %then %do; function='move'; x=0; y=&&g&one._selected_threshold+&gap_start; output clean_anno_p&two.p&one anno_p&two.p&one; function='bar'; x=100; y=&&g&one._selected_threshold+&gap_start+&gap_width; color='white'; output clean_anno_p&two.p&one anno_p&two.p&one; color='red'; size=1; line=1; function='move'; xsys='1'; x=0; ysys='2'; y=&&g&one._selected_threshold+&gap_start; output clean_anno_p&two.p&one anno_p&two.p&one; function='draw'; xsys='B'; ysys='B'; x=+100; y=+0; output clean_anno_p&two.p&one anno_p&two.p&one; function='move'; xsys='1'; x=0; ysys='2'; y=&&g&one._selected_threshold+&gap_start+&gap_width; output clean_anno_p&two.p&one anno_p&two.p&one; function='draw'; xsys='B'; ysys='B'; x=+100; y=+0; output clean_anno_p&two.p&one anno_p&two.p&one; %end; %do i=1 %to &rounds; function='label'; xsys='2'; x=&&r&i._mid_interval+1; ysys='2'; y=0; position='8'; text="Round &i"; style='centxi'; color='black'; size=1; output anno_p&two.p&one; %end; when='b'; function='move'; xsys='1'; x=0; ysys='2'; y=min(&&c&one._g&one._oc_value,&&c&two._g&one._oc_value); output clean_anno_p&two.p&one anno_p&two.p&one; function='bar'; xsys='1'; x=100; ysys='2'; y=max(&&c&one._g&one._oc_value,&&c&two._g&one._oc_value); style='solid'; color='CXccccff'; output clean_anno_p&two.p&one anno_p&two.p&one; run; axis1 minor=none value=(font=swiss) offset=(2,2) label=none width=2 %if &gap_range > 4 %then %do; order=(0 to &&g&one._selected_threshold by 1, &&g&one._max ); %end; %else %do; order=(0 to &&g&one._max by 1); %end; axis2 major=none minor=none value=none offset=(2,2) label=(font=simplex "Relative Price of &&g&one._name Across Time Intervals (%cmpres(&interval_seconds.) secs)" ) width=2 order=(1 to &int_max by 1); symbol1 i=boxft00 bwidth=2 width=1 cv='CXcc9933' co=blue ci=black; symbol2 i=none v=dot c='CXffcc00' height=1 width=1 /*pointlabel=(font=swissx h=1 c=black j=l position=top "#mrp_g&one.")*/; proc gplot data=plot_relative_prices imagemap=out.p&two.p&one.dat; plot rp_g&one.*int_id=1 mrp_g&one.*int_id=2 / overlay anno=anno_p&two.p&one. vaxis=axis1 haxis=axis2 /*frame*/ autovref cvref=grey lvref=2 href=(&interval_boundary_list) chref=grey lhref=5 html=&pdrill name="rp_g&one."; *note move=(40,-1.5) blank=yes font=centxi height=2 "&game_name"; run; quit; symbol1 i=none v=dot width=.5 height=.5 c='CX000000'; axis2 major=none minor=none value=none offset=(2,2) label=(font=simplex "Relative Price of &&g&one._name Ordered by Bought Time") order=(1 to &obs_rpg_max by 1); proc gplot data=work.plot_game_market; plot rp_g&one.*obs_rpg=1 / anno=clean_anno_p&two.p&one. vaxis=axis1 haxis=axis2 autovref cvref=grey lvref=2 name="r_rp_g&one."; where (good_1=&&g&one._id); *seller good type; run; quit; %mend; %plot_rpgs(rpg=rp_g1,one=1,two=2,pdrill=pdrill1); %plot_rpgs(rpg=rp_g2,one=2,two=1,pdrill=pdrill2); /* AUTARKY */ %macro autarky; data anno_autarky anno_autarky1 anno_autarky2; length function text style color $8; retain xsys '1' ysys '2' when 'b'; function='move'; x=0; y=&c1_g1_oc_value; output anno_autarky; function='bar'; x=100; y=&c1_g2_oc_value; style='R2'; color='CXcccccc'; output anno_autarky; function='move'; x=0; y=&c2_g1_oc_value; output anno_autarky; function='bar'; x=100; y=&c2_g2_oc_value; style='L2'; color='blue'; output anno_autarky; function='move'; x=0; y=min(&c1_g1_oc_value,&c2_g1_oc_value); output anno_autarky1; function='bar'; x=100; y=max(&c1_g1_oc_value,&c2_g1_oc_value); style='solid'; color='CXccccff'; output anno_autarky1; function='move'; x=0; y=min(&c1_g2_oc_value,&c2_g2_oc_value); output anno_autarky2; function='bar'; x=100; y=max(&c1_g2_oc_value,&c2_g2_oc_value); style='solid'; color='CXccccff'; output anno_autarky2; color='white'; size=1; line=1; function='move'; xsys='1'; x=0; ysys='2'; y=&c1_g1_oc_value; output anno_autarky; function='draw'; xsys='B'; ysys='B'; x=+100; y=+0; output anno_autarky; function='move'; xsys='1'; x=0; ysys='2'; y=&c1_g2_oc_value; output anno_autarky; function='draw'; xsys='B'; ysys='B'; x=+100; y=+0; output anno_autarky; function='move'; xsys='1'; x=0; ysys='2'; y=&c2_g1_oc_value; output anno_autarky; function='draw'; xsys='B'; ysys='B'; x=+100; y=+0; output anno_autarky; function='move'; xsys='1'; x=0; ysys='2'; y=&c2_g2_oc_value; output anno_autarky; function='draw'; xsys='B'; ysys='B'; x=+100; y=+0; output anno_autarky; %do i=1 %to &rounds; function='label'; xsys='2'; x=&&r&i._mid_interval+1; ysys='2'; y=0; position='8'; text="Round &i"; style='centxi'; color='black'; size=1; output anno_autarky anno_autarky1 anno_autarky2; %end; function='move'; when='a'; xsys='5'; x=70; ysys='5'; y=90; output anno_autarky; function='bar'; line=0; x=82; y=95; style='R2'; color='CXcccccc'; output anno_autarky; function='move'; when='a'; xsys='5'; x=80; ysys='5'; y=90; output anno_autarky; function='bar'; line=0; x=92; y=95; style='L2'; color='blue'; output anno_autarky; function='label'; when='a'; xsys='5'; x=81; ysys='5'; y=90; text="&c1_g1_oc_name.=&c1_g1_oc_value. "; position='7'; style='duplex'; color='grey'; size=1; output anno_autarky; function='label'; when='a'; xsys='5'; x=81; ysys='5'; y=87; text="&c1_g2_oc_name.=&c1_g2_oc_value. "; position='7'; style='duplex'; color='grey'; size=1; output anno_autarky; function='label'; when='a'; xsys='5'; x=81; ysys='5'; y=90; text=" &c2_g1_oc_name.=&c2_g1_oc_value."; position='9'; style='duplex'; color='blue'; size=1; output anno_autarky; function='label'; when='a'; xsys='5'; x=81; ysys='5'; y=87; text=" &c2_g2_oc_name.=&c2_g2_oc_value."; position='9'; style='duplex'; color='blue'; size=1; output anno_autarky; run; %local max_y; %put y=&mrp_g1_max &mrp_g2_max; %if %sysevalf(&mrp_g1_max>&mrp_g2_max) %then %do; %let max_y=%sysevalf(&mrp_g1_max+0.1); %end; %if %sysevalf(&mrp_g1_max<&mrp_g2_max) %then %do; %let max_y=%sysevalf(&mrp_g1_max+0.1); %end; %put y=&max_y; axis1 minor=none value=(font=swiss) offset=(2,2) label=none width=2 order=(0 to &max_y); axis2 major=none value=none offset=(2,2) label=(font=simplex "Average Relative Prices Across Time Intervals (%cmpres(&interval_seconds.) secs)" ) order=(1 to &int_max by 1) width=2; symbol1 i=spline v=dot c='CXcc9933' height=1 width=2; symbol2 i=spline v=dot c='CX33cc00' height=1 width=2; legend1 label=(font=centb "Avg Relatives Prices") position=(top left inside) value=(font=centb color=CXcc9933 "&g1_name" font=centb color=CX33cc00 "&g2_name") across=2 down=1 frame; title1; data out.palldat; set out.p2p1dat out.p1p2dat; run; proc gplot data=plot_relative_prices imagemap=out.palldat; plot mrp_g1*int_id=1 mrp_g2*int_id=2 / overlay anno=anno_autarky legend=legend1 html=pdrill vaxis=axis1 haxis=axis2 /*frame*/ autovref cvref=grey lvref=2 href=(&interval_boundary_list) chref=grey lhref=5 name='autarky'; run; symbol1 i=spline v=dot c='CXcc9933' height=1 width=2; proc gplot data=plot_relative_prices imagemap=out.p2p1dat; plot mrp_g1*int_id=1 / anno=anno_autarky1 nolegend html=pdrill vaxis=axis1 haxis=axis2 /*frame*/ autovref cvref=grey lvref=2 href=(&interval_boundary_list) chref=grey lhref=5 name='autarky1'; run; symbol1 i=spline v=dot c='CX33cc00' height=1 width=2; proc gplot data=plot_relative_prices imagemap=out.p1p2dat; plot mrp_g2*int_id=1 / anno=anno_autarky2 nolegend html=pdrill vaxis=axis1 haxis=axis2 /*frame*/ autovref cvref=grey lvref=2 href=(&interval_boundary_list) chref=grey lhref=5 name='autarky2'; run; quit; %mend; %autarky; /* POSSIBILITY FRONTIER */ %macro ppf(nr=,nr2=); %do rnr=1 %to &rounds; %do gtl=1 %to 2; %if >l=1 %then %do; %let g1=g1_produced; %let g2=g2_produced; %let rpt_pointer=rpt_produced; %end; %if >l=2 %then %do; %let g1=g1_consumed; %let g2=g2_consumed; %let rpt_pointer=rpt_consumed; %end; proc sort data=work.plot_ppf out=work.plot_ppf_thisround; by &g1 &g2; where country=&&c&nr._id and round=&rnr; run; data dot_counts(keep=dot_count &g1 &g2); retain dot_count 0; set work.plot_ppf_thisround end=last; by &g1 &g2; if &g1=lag1(&g1) and &g2=lag1(&g2) then dot_count=dot_count+1; else dot_count=1; if last.&g2 and dot_count>1 then output; if last then do; * empty obs; dot_count=-1;&g1=0;&g2=0; output; end; run; data anno_ppf anno_ppf_clear; length function style color text $8; retain ; retain header 0; set work.dot_counts; if (header=0) then do; when='b'; color='CXcccccc'; size=2; line=1; function='move'; xsys='2'; x=0; ysys='2'; y=&&c&nr._g1_ppf; output anno_ppf anno_ppf_clear; function='draw'; xsys='2'; x=+&&c&nr._g2_ppf; ysys='2'; y=+0; output anno_ppf anno_ppf_clear; function='label'; xsys='5'; x=95; ysys='5'; y=96; position='D'; text="&rnr"; style='swissb'; color='black'; size=1; output anno_ppf anno_ppf_clear; function='label'; xsys='5'; x=95; ysys='5'; y=90; position='D'; text="&&c&nr._ppf_slope"; style='swissb'; color='CXcccccc'; size=1; output anno_ppf anno_ppf_clear; end; if dot_count>1 and (&g1+&g2>0)then do; when='a'; color='CX666666'; size=1; line=1; function='move'; xsys='2'; x=&g2; ysys='2'; y=&g1; output anno_ppf ; function='draw'; xsys='2'; x=+&g2+&&c&nr._g2_ppf_add*0.35; ysys='2'; y=+&g1+&&c&nr._g1_ppf_add*0.45; output anno_ppf ; function='label'; xsys='2'; x=&g2+&&c&nr._g2_ppf_add*0.35; ysys='2'; y=&g1+&&c&nr._g1_ppf_add*0.45; position='C'; text=trim(left(dot_count)); style='centxi'; color='CX666666'; size=1; output anno_ppf ; end; drop header &g1 &g2 dot_count; run; goptions xpixels=250 ypixels=250; axis1 label=none /*(font=simplex angle=90 "Units of &g1_name")*/ value=none minor=none width=2 /*order=(0 to &&c&nr._g1_ppf_max by &&c&nr._g1_ppf_add)*/ order=(0 to %sysevalf(((&max_g1_consumed+&max_g1_consumed_add)/&max_g1_consumed_add)*&max_g1_consumed_add) by &max_g1_consumed_add) offset=(2,2); axis2 label=none /*(font=simplex "Units of &g2_name")*/ value=none minor=none width=2 /*order=(0 to &&c&nr._g2_ppf_max by &&c&nr._g2_ppf_add)*/ order=(0 to %sysevalf(((&max_g2_consumed+&max_g2_consumed_add)/&max_g2_consumed_add)*&max_g2_consumed_add) by &max_g2_consumed_add) offset=(2,2); %if %eval(>l=1) %then %do; * for each round, for each country, a clear graph; title1; symbol1 i=none v=none; proc gplot data=work.plot_ppf_thisround; plot &g1*&g2=anonymous / anno=anno_ppf_clear nolegend href=(0) vref=(0) vaxis=axis1 haxis=axis2 /*frame*/ name="ppf0&nr.&rnr"; where (&g1+&g2>0); run; * for each round, for each country, the ind graph; data work.plot_ppf_indifference(keep=ind_x ind0_y ind1_y ind2_y ind3_y) work.plot_ppf_indifference_labels(keep=firstx firsty0 firsty1 firsty2 firsty3) ; retain top0 top1 top2 top3 0; retain firstx 0; * albertos numerical example; L = &&c&nr._labor; aLg2 = &&c&nr._g&nr2._laborcost_unit; aLg1 = &&c&nr._g&nr._laborcost_unit; r1 = 1/(1-&rho); r2 = -&rho/(1-&rho); W = L/((aLg2**r1)*(aLg1**r2)+aLg2); C = L/((aLg2**r2)*(aLg1**r1)+aLg1); U = (W**&rho+C**&rho)**(1/&rho); * walk the x; *do ind_x=&&c&nr._g2_ppf_max to (&&c&nr._g2_ppf_add/10) by -1*(&&c&nr._g2_ppf_add/10); do ind_x=&max_g2_consumed to 1 by -1; ind0_y = ((0.5*U)**&rho-(ind_x)**&rho)**(1/&rho); ind1_y = ((U)**&rho-(ind_x)**&rho)**(1/&rho); ind2_y = ((1.5*U)**&rho-(ind_x)**&rho)**(1/&rho); ind3_y = ((2.0*U)**&rho-(ind_x)**&rho)**(1/&rho); if firstx=0 and ind1_y^=. then do; firstx=ind_x+(&max_g2_consumed_add/4); firsty0=ind0_y; firsty1=ind1_y; firsty2=ind2_y; firsty3=ind3_y; output work.plot_ppf_indifference_labels; end; if ind0_y>(&max_g1_consumed+&max_g1_consumed_add*0.90) or ind0_y=. then do; if top0=0 then do; top0=1; ind0_y=%eval(((&max_g1_consumed+&max_g1_consumed_add)/&max_g1_consumed_add)*&max_g1_consumed_add); end; else ind0_y=.; end; if ind1_y>(&max_g1_consumed+&max_g1_consumed_add*0.90) or ind1_y=. then do; if top1=0 then do; top1=1; ind1_y=%eval(((&max_g1_consumed+&max_g1_consumed_add)/&max_g1_consumed_add)*&max_g1_consumed_add); end; else ind1_y=.; end; if ind2_y>(&max_g1_consumed+&max_g1_consumed_add*0.90) or ind2_y=. then do; if top2=0 then do; top2=1; ind2_y=%eval(((&max_g1_consumed+&max_g1_consumed_add)/&max_g1_consumed_add)*&max_g1_consumed_add); end; else ind2_y=.; end; if ind3_y>(&max_g1_consumed+&max_g1_consumed_add*0.90) or ind3_y=. then do; if top3=0 then do; top3=1; ind3_y=%eval(((&max_g1_consumed+&max_g1_consumed_add)/&max_g1_consumed_add)*&max_g1_consumed_add); end; else ind3_y=.; end; output work.plot_ppf_indifference; end; run; data anno_ppf_indifference_misc; length function style color $8 text $3; retain; set work.plot_ppf_indifference_labels; when='b'; function='label'; position='6'; style='centxi'; color='CXcccccc'; size=.75; xsys='2'; x=firstx; ysys='2'; y=firsty0; text='0.5'; output; xsys='2'; x=firstx; ysys='2'; y=firsty1; text='1.0'; output; xsys='2'; x=firstx; ysys='2'; y=firsty2; text='1.5'; output; xsys='2'; x=firstx; ysys='2'; y=firsty3; text='2.0'; output; /* when='a'; function='label'; position='1'; style='marker'; color='CX00ff00'; size=1; xsys='2'; x=%trim(&pointx1); ysys='2'; y=%trim(&pointy1); text='V'; */ run; data anno_ppf_indifference; set anno_ppf_clear anno_ppf_indifference_misc; run; title1; symbol1 i=join v=none height=.1 width=.1 color='CXcccccc'; proc gplot data=work.plot_ppf_indifference; plot ind0_y*ind_x=1 ind1_y*ind_x=1 ind2_y*ind_x=1 ind3_y*ind_x=1/ overlay anno=anno_ppf_indifference nolegend href=(0) vref=(0) vaxis=axis1 haxis=axis2 /*frame*/ name="ind0&nr.&rnr"; run; quit; proc sort data=work.plot_ppf out=work.plot_ppf_lines_thisround; by username; where country=&&c&nr._id and round=&rnr; run; /* proc print data=work.plot_ppf_lines_thisround; var username g1_produced g2_produced g1_consumed g2_consumed; run; */ data anno_ppf_lines; length function style color $8; retain xsys '1' ysys '2' when 'b'; set work.plot_ppf_lines_thisround; when='a'; color='CX666666'; size=1; line=1; function='move'; xsys='2'; x=g2_produced; ysys='2'; y=g1_produced; output; function='draw'; xsys='2'; x=+g2_consumed; ysys='2'; y=+g1_consumed; output; run; data anno_ppf_lines; set work.anno_ppf_lines work.anno_ppf_clear; run; title1; %if &nr=1 %then %do; symbol1 i=none v=dot c="CX&ppfdotcolor1" height=.5 width=.5; symbol2 i=none v=dot c="CX&ppfdotcolor3" height=.5 width=.5; %end; %if &nr=2 %then %do; symbol1 i=none v=dot c="CX&ppfdotcolor2" height=.5 width=.5; symbol2 i=none v=dot c="CX&ppfdotcolor4" height=.5 width=.5; %end; proc gplot data=work.plot_ppf_lines_thisround; plot g1_produced*g2_produced=1 g1_consumed*g2_consumed=2 / overlay anno=anno_ppf_lines nolegend href=(0) vref=(0) vaxis=axis1 haxis=axis2 /*frame*/ name="pac0&nr.&rnr"; run; quit; /****** to delete? proc sort data=work.plot_ppf_d2l out=work.plot_ppf_d2l_thisround; by username; where country=&&c&nr._id and round=&rnr; run; data anno_ppf_d2l; length function style color $8; retain xsys '1' ysys '2' when 'b'; set work.plot_ppf_d2l_thisround; if _n_=1 then do; function='move'; xsys='2'; x=0; ysys='2'; y=0; output; function='draw'; line=20; xsys='2'; x=+&&c&nr._g2_ppf; ysys='2'; y=+&&c&nr._g1_ppf; output; end; when='a'; color='CX666666'; size=1; line=1; function='move'; xsys='2'; x=d2l_origin_x; ysys='2'; y=d2l_origin_y; output; function='draw'; xsys='2'; x=+g2_consumed; ysys='2'; y=+g1_consumed; output; function='label'; xsys='2'; x=g2_consumed*1.10; ysys='2'; y=g1_consumed*1.10; position='C'; text=trim(left(d2l)); style='centxi'; color='CX666666'; size=1; output; run; data anno_ppf_d2l; set work.anno_ppf_d2l work.anno_ppf_clear; run; title1; %if &nr=1 %then %do; symbol1 i=none v=dot c="CX&ppfdotcolor3" height=.5 width=.5; %end; %if &nr=2 %then %do; symbol1 i=none v=dot c="CX&ppfdotcolor4" height=.5 width=.5; %end; proc gplot data=work.plot_ppf_d2l_thisround; plot g1_consumed*g2_consumed=1 / anno=anno_ppf_d2l nolegend href=(0) vref=(0) vaxis=axis1 haxis=axis2 name="d2l0&nr.&rnr"; run; quit; **********/ %end; %if &nr=1 and >l=1 %then %do; symbol1 i=none v=dot c="CX&ppfdotcolor1" height=1 width=2; %end; %if &nr=2 and >l=1 %then %do; symbol1 i=none v=dot c="CX&ppfdotcolor2" height=1 width=2; %end; %if &nr=1 and >l=2 %then %do; symbol1 i=none v=dot c="CX&ppfdotcolor3" height=1 width=2; %end; %if &nr=2 and >l=2 %then %do; symbol1 i=none v=dot c="CX&ppfdotcolor4" height=1 width=2; %end; title1; *ods html path="&out" body="rpt>l.&nr.&rnr..html"; proc gplot data=work.plot_ppf_thisround imagemap=work.imagemap_thisround; plot &g1*&g2=anonymous / anno=anno_ppf html=&rpt_pointer nolegend href=(0) vref=(0) vaxis=axis1 haxis=axis2 /*frame*/ name="ppf>l.&nr.&rnr"; where (&g1+&g2>0); run; quit; *ods html close; %end; %end; %mend; %ppf(nr=1,nr2=2); %ppf(nr=2,nr2=1);