OPTIONS PS = 60; OPTIONS LS = 70; options center; * Here I read the data. You will need to change the directory name to the location of the data on your machine; PROC IMPORT OUT= WORK.process DATAFILE= "C:\Ernan\A-D\bubbles\Belief_project\Yaron\FilesForTradersExpectations_AER\TraderFull.xls" DBMS=EXCEL REPLACE; SHEET="Data$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; * Computing the peak price; proc means data=process; var EqmPrice; class session market; output out=bubblepeak max(EqmPrice)=peak; run; * Merging the main dataset with the price peak information and then keepinly only the period in which price is at its peak; proc sort data=process; by session market; run; proc sort data=bubblepeak; by session market; run; data peakround; merge process bubblepeak; by session market; if EqmPrice=peak then apeakround=round; if EqmPrice ne peak then delete; if session=. or market=. then delete; run; * Keeping only the last round where price peaked (we only allow one peak period in a market); proc sort data=peakround; by session market descending round; run; data peakround; set peakround; lmarket=lag(market); lsession = lag(session); if session = lsession and market = lmarket then delete; run; * Computing the peak in beliefs; data peakbeliefs; set process; peak=max(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15); if b1=peak then bpeakround=1; if b2=peak then bpeakround=2; if b3=peak then bpeakround=3; if b4=peak then bpeakround=4; if b5=peak then bpeakround=5; if b6=peak then bpeakround=6; if b7=peak then bpeakround=7; if b8=peak then bpeakround=8; if b9=peak then bpeakround=9; if b10=peak then bpeakround=10; if b11=peak then bpeakround=11; if b12=peak then bpeakround=12; if b13=peak then bpeakround=13; if b14=peak then bpeakround=14; if b15=peak then bpeakround=15; run; * Deleting all but round 3; data peakbeliefs_round3; set peakbeliefs; if round ne 3 then delete; elicitation_round=3; run; * Deleting all but round 4; data peakbeliefs_round4; set peakbeliefs; if round ne 4 then delete; elicitation_round=4; run; proc sort data=peakround; by session market; run; proc sort data=peakbeliefs_round3; by session market; run; proc sort data=peakbeliefs_round4; by session market; run; data peakround3; merge peakbeliefs_round3 peakround; by session market; diff3 = apeakround - bpeakround; run; data peakround4; merge peakbeliefs_round4 peakround; by session market; diff3 = apeakround - bpeakround; run; data peakround; set peakround3 peakround4; run; proc sort; by elicitation_round market session round; run; * Creating Market dummies and deleting market 1; data peakround; set peakround; if market=1 then delete; if market=2 then M2=1; else M2=0; if market=3 then M3=1; else M3=0; run; * The regression itself; proc glm data=peakround; model diff3 = M2 M3; by elicitation_round; run;