
/*** NOTE: w is the name of the directory where the datasets are stored *****/


/***  # prompt deserved in no prompt condition ****/
proc freq data=w.exp1data;
where fred1=3;
table deservedtotal;
run;
proc freq data=w.exp2data;
where fred1=3 ;
table deservedtotal;
run;
proc freq data=w.exp3data;
where fred1a=3 ;
table deservedtotal;
run;
proc freq data=w.exp4data;
where fred2a=2 and fred1b=2;
table deservedtotal;
run;
proc freq data=w.exp5data;
where promptcond_jul=2;
table deservedtotal_jul;
run;
proc freq data=w.exp5data;
where promptcond_aug=2;
table deservedtotal_aug;
run;


/***  distribution of speeding incidences among those who sped at least once in the control condition ****/

proc freq data=w.exp1data;
where fred1=3 and prompt3cat12>=2;
table deservedtotal;
run;
proc freq data=w.exp2data;
where fred1=3 and prompt3cat12>=2;
table deservedtotal;
run;
proc freq data=w.exp3data;
where fred1a=3 and prompt3cat12>=2;
table deservedtotal;
run;
proc freq data=w.exp4data;
where fred2a=2 and fred1b=2 and prompt3cat12>=2;
table deservedtotal;
run;
proc freq data=w.exp5data;
where promptcond_jul=2 and prompt3cat12_jul>=2;
table deservedtotal_jul;
run;
proc freq data=w.exp5data;
where promptcond_aug=2 and prompt3cat12_aug>=2;
table deservedtotal_aug ;
run;


/**** Impact of intervention on subsequent speeding ****/

*** Conditional on deserving/receiving >=1 prompt;
*** Table 2: # of PROMPTS RECEIVED/DESERVED (Q2-Q7);
*** Exp1;

 proc glm data=w.exp1data;
 where prompt3cat12>=2 and fred1 in (1,2,3); * All 3 conditions;
 class fred1;
 model deservedtotalq66q69 = fred1;
 lsmeans fred1 / pdiff=all adjust=tukey;
 run;
 quit;

 proc glm data=w.exp1data;
 where prompt3cat12>=2 and fred1 in (1,2); * Prompt Every Time vs. Prompt Once;
 class fred1;
 model deservedtotalq66q69 = fred1;
 lsmeans fred1 / pdiff=all adjust=tukey;
 run;
 quit;


 *** Exp2;

 proc glm data=w.exp2data;
 where prompt3cat12>=2 and fred1 in (1,2,3);
 class fred1;
 model deservedtotalq66q69 = fred1;
 lsmeans fred1 / pdiff=all adjust=tukey;
 run;
 quit;

  proc glm data=w.exp2data;
 where prompt3cat12>=2 and fred1 in (1,2);
 class fred1;
 model deservedtotalq66q69 = fred1;
 lsmeans fred1 / pdiff=all adjust=tukey;
 run;
 quit;


 *** Exp3;

 proc glm data=w.exp3data;
 where deservedtotal>=1 and fred1a in (1,2,3);
 class fred1a;
 model deservedtotalq5q8= fred1a ;
 lsmeans fred1a/ pdiff=all adjust=tukey;
 run;
 quit; 

 proc glm data=w.exp3data;
 where deservedtotal>=1 and fred1a in (1,2);
 class fred1a;
 model deservedtotalq5q8= fred1a ;
 lsmeans fred1a/ pdiff=all adjust=tukey;
 run;
 quit; 


 *** Exp4;
  proc glm data=w.exp4data;
 where deservedtotal>=1 and fred1b=2;
 class fred2a;
 model deservedtotalq15q20= fred2a ;
 lsmeans fred2a/ pdiff=all adjust=tukey;
 run;
 quit; 

  

 *** Exp5a;

 proc glm data=w.exp5data; 
 where deservedtotal_jul>=1 ;
 class promptcond_jul;
 model deservedtotalq9q14_jul=promptcond_jul;
 lsmeans promptcond_jul/ pdiff=all adjust=tukey;
 run;
 quit; 

 *** Exp5b;

 proc glm data=w.exp5data; 
 where deservedtotal_aug>=1 ;
 class promptcond_aug;
 model deservedtotalq9q14_aug=promptcond_aug;
 lsmeans promptcond_aug/ pdiff=all adjust=tukey;
 run;
 quit; 


*** Table 3: Percent of respondents who sped after speeding on previous Qs ;

*** Exp1;
proc freq data=w.exp1data;
where deservedpromptq65=1 and fred1 in (1,2,3);
tables deservedpromptq66*fred1/chisq;
run;

proc freq data=w.exp1data;
where (deservedpromptq65=1 or deservedpromptq66=1) 
and fred1 in (1,2,3);
tables deservedpromptq67*fred1/chisq;
run;


proc freq data=w.exp1data;
where (deservedpromptq65=1 or deservedpromptq66=1
or deservedpromptq67=1 )
and fred1 in (1,2,3);
tables deservedpromptq67b*fred1/chisq;
run;

proc freq data=w.exp1data;
where (deservedpromptq65=1 or deservedpromptq66=1
or deservedpromptq67=1 
or deservedpromptq67b=1 )
and fred1 in (1,2,3);
tables deservedpromptq67c*fred1/chisq;
run;

proc freq data=w.exp1data;
where ( deservedpromptq65=1 or deservedpromptq66=1
or deservedpromptq67=1 
or deservedpromptq67b=1 
or deservedpromptq67c=1 )
and fred1 in (1,2,3);
tables deservedpromptq68*fred1/chisq;
run;

proc freq data=w.exp1data;
where (deservedpromptq65=1 or deservedpromptq66=1
or deservedpromptq67=1 
or deservedpromptq67b=1 
or deservedpromptq67c=1 
or deservedpromptq68=1 )
and fred1 in (1,2,3);
tables deservedpromptq69*fred1/chisq;
run;


*** Exp2;

proc freq data=w.exp2data;
where deservedpromptq65=1 and fred1 in (1,2,3);
tables deservedpromptq66*fred1/chisq;
run;

proc freq data=w.exp2data;
where (deservedpromptq65=1 or deservedpromptq66=1) 
and fred1 in (1,2,3);
tables deservedpromptq67*fred1/chisq;
run;

proc freq data=w.exp2data;
where (deservedpromptq65=1 or deservedpromptq66=1
or deservedpromptq67=1 )
and fred1 in (1,2,3);
tables deservedpromptq67b*fred1/chisq;
run;


proc freq data=w.exp2data;
where (deservedpromptq65=1 or deservedpromptq66=1
or deservedpromptq67=1 
or deservedpromptq67b=1 )
and fred1 in (1,2,3);
tables deservedpromptq67c*fred1/chisq;
run;

proc freq data=w.exp2data;
where ( deservedpromptq65=1 or deservedpromptq66=1
or deservedpromptq67=1 
or deservedpromptq67b=1 
or deservedpromptq67c=1 )
and fred1 in (1,2,3);
tables deservedpromptq68*fred1/chisq;
run;

proc freq data=w.exp2data;
where (deservedpromptq65=1 or deservedpromptq66=1
or deservedpromptq67=1 
or deservedpromptq67b=1 
or deservedpromptq67c=1 
or deservedpromptq68=1 )
and fred1 in (1,2,3);
tables deservedpromptq69*fred1/chisq;
run;

*** Exp3;

proc freq data=w.exp3data;
where deservedpromptq4=1 and fred1a in (1,2,3);
tables deservedpromptq5*fred1a/chisq;
run;

proc freq data=w.exp3data;
where (deservedpromptq4=1 or deservedpromptq5=1) and fred1a in (1,2,3);
tables deservedpromptq6a*fred1a/chisq;
run;

proc freq data=w.exp3data;
where (deservedpromptq4=1 or deservedpromptq5=1 
or deservedpromptq6a=1 )
and fred1a in (1,2,3);
tables deservedpromptq6b*fred1a/chisq;
run;


proc freq data=w.exp3data;
where (deservedpromptq4=1 or deservedpromptq5=1 
or deservedpromptq6a=1 
or deservedpromptq6b=1 )
and fred1a in (1,2,3);
tables deservedpromptq6c*fred1a/chisq;
run;

proc freq data=w.exp3data;
where (deservedpromptq4=1 or deservedpromptq5=1 
or deservedpromptq6a=1 
or deservedpromptq6b=1 
or deservedpromptq6c=1 )
and fred1a in (1,2,3);
tables deservedpromptq7*fred1a/chisq;
run;

proc freq data=w.exp3data;
where (deservedpromptq4=1 or deservedpromptq5=1 
or deservedpromptq6a=1 
or deservedpromptq6b=1 
or deservedpromptq6c=1 
or deservedpromptq7=1) 
and fred1a in (1,2,3);
tables deservedpromptq8*fred1a/chisq;
run;

*** Exp4;
proc freq data=w.exp4data;
where deservedpromptq14=1 and fred2a >=1 and fred1b=2;
tables deservedpromptq15*fred2a/chisq;
run;
proc freq data=w.exp4data;
where (deservedpromptq14=1 or deservedpromptq15=1) and fred2a >=1 and fred1b=2;
tables deservedpromptq16*fred2a/chisq;
run;
proc freq data=w.exp4data;
where (deservedpromptq14=1 or deservedpromptq15=1 or deservedpromptq16=1) and fred2a >=1 and fred1b=2;
tables deservedpromptq17*fred2a/chisq;
run;
proc freq data=w.exp4data;
where (deservedpromptq14=1 or deservedpromptq15=1 or deservedpromptq16=1 
or deservedpromptq17=1) and fred2a >=1 and fred1b=2;
tables deservedpromptq18*fred2a/chisq;
run;
proc freq data=w.exp4data;
where (deservedpromptq14=1 or deservedpromptq15=1 or deservedpromptq16=1 
or deservedpromptq17=1 or deservedpromptq18=1) and fred2a >=1 and fred1b=2;
tables deservedpromptq19*fred2a/chisq;
run;
proc freq data=w.exp4data;
where (deservedpromptq14=1 or deservedpromptq15=1 or deservedpromptq16=1 
or deservedpromptq17=1 or deservedpromptq18=1 or deservedpromptq19=1) and fred2a>=1 and fred1b=2;
tables deservedpromptq20*fred2a/chisq;
run;

*** Exp 5a;

proc freq data=w.exp5data;
where deservedpromptq8_jul=1 and promptcond_jul >=1 ;
tables deservedpromptq9_jul*promptcond_jul/chisq;
run;
proc freq data=w.exp5data;
where (deservedpromptq8_jul=1 or deservedpromptq9_jul=1) and promptcond_jul >=1 ;
tables deservedpromptq10_jul*promptcond_jul/chisq;
run;
proc freq data=w.exp5data;
where (deservedpromptq8_jul=1 or deservedpromptq9_jul=1 or deservedpromptq10_jul=1) and promptcond_jul >=1 ;
tables deservedpromptq11_jul*promptcond_jul/chisq;
run;
proc freq data=w.exp5data;
where (deservedpromptq8_jul=1 or deservedpromptq9_jul=1 or deservedpromptq10_jul=1 
or deservedpromptq11_jul=1) and promptcond_jul >=1 ;
tables deservedpromptq12_jul*promptcond_jul/chisq;
run;
proc freq data=w.exp5data;
where (deservedpromptq8_jul=1 or deservedpromptq9_jul=1 or deservedpromptq10_jul=1 
or deservedpromptq11_jul=1 or deservedpromptq12_jul=1) and promptcond_jul >=1 ;
tables deservedpromptq13_jul*promptcond_jul/chisq;
run;
proc freq data=w.exp5data;
where (deservedpromptq8_jul=1 or deservedpromptq9_jul=1 or deservedpromptq10_jul=1 
or deservedpromptq11_jul=1 or deservedpromptq12_jul=1 or deservedpromptq13_jul=1) and promptcond_jul>=1;
tables deservedpromptq14_jul*promptcond_jul/chisq;
run;

*** Exp 5b;

proc freq data=w.exp5data;
where deservedpromptq8_aug=1 and promptcond_aug >=1 ;
tables deservedpromptq9_aug*promptcond_aug/chisq;
run;
proc freq data=w.exp5data;
where (deservedpromptq8_aug=1 or deservedpromptq9_aug=1) and promptcond_aug >=1 ;
tables deservedpromptq10_aug*promptcond_aug/chisq;
run;
proc freq data=w.exp5data;
where (deservedpromptq8_aug=1 or deservedpromptq9_aug=1 or deservedpromptq10_aug=1) and promptcond_aug >=1 ;
tables deservedpromptq11_aug*promptcond_aug/chisq;
run;
proc freq data=w.exp5data;
where (deservedpromptq8_aug=1 or deservedpromptq9_aug=1 or deservedpromptq10_aug=1 
or deservedpromptq11_aug=1) and promptcond_aug >=1 ;
tables deservedpromptq12_aug*promptcond_aug/chisq;
run;
proc freq data=w.exp5data;
where (deservedpromptq8_aug=1 or deservedpromptq9_aug=1 or deservedpromptq10_aug=1 
or deservedpromptq11_aug=1 or deservedpromptq12_aug=1) and promptcond_aug >=1 ;
tables deservedpromptq13_aug*promptcond_aug/chisq;
run;
proc freq data=w.exp5data;
where (deservedpromptq8_aug=1 or deservedpromptq9_aug=1 or deservedpromptq10_aug=1 
or deservedpromptq11_aug=1 or deservedpromptq12_aug=1 or deservedpromptq13_aug=1) and promptcond_aug>=1;
tables deservedpromptq14_aug*promptcond_aug/chisq;
run;


/*** Effect of prompts throughout the qnaire *****/

proc glm data=w.exp3data;
 where deservedtotal>=1 and fred1a>=1 and fred1b>=1;
 class fred1a freq_early;
 model deservedtotal = fred1a freq_early fred1a*freq_early;
 lsmeans fred1a*freq_early / pdiff=all adjust=tukey;
 run;
 quit;

proc glm data=w.exp3data;
 where deservedtotal>=1 and fred1a>=1;
 class fred1a freq_early;
 model deservedtotal = fred1a freq_early fred1a*freq_early;
 lsmeans fred1a*freq_early / pdiff=all adjust=tukey;
 run;
 quit;


/**** accuracy of the numeric questions ****/

*** by prompt conditions ;

proc freq data=w.exp4data;
where fred1b=2 and fred2a>=1 and edu3cat>=1 and ((fred1a=1 and s2=1) or fred1a=2) and prompt3cat12>=2;
tables q14q20_true67*fred2a/chisq;
run;


*** by education and prompt conditions;

proc freq data=w.exp4data;
where fred1b=2 and fred2a>=1 and edu3cat>=1 and ((fred1a=1 and s2=1) or fred1a=2) and prompt3cat12>=2;
tables edu3cat*q14q20_true67*fred2a/chisq;
run;


/**** speeding and straightlining  ****/

*** association between two behaviors (control condition only/Figure 3);

proc freq data=w.exp1data;
where fred1=3;
tables deservedtotal*sliner/chisq;
run;**not sig;
proc freq data=w.exp2data;
where fred1=3;
tables deservedtotal*sliner/chisq;
run;
proc freq data=w.exp3data;
where fred1a=3 ;
tables deservedtotal*sliner/chisq;
run;
proc freq data=w.exp4data;
where fred2a=2 and fred1b=2;
tables deservedtotal*sliner/chisq;
run;


*** effect of earlier prompts on straightlining ;

proc freq data=w.exp1data;
where prompt3cat12>=2 and fred1 in (1,2,3);
tables fred1*sliner /chisq;
run;**not sig;

proc freq data=w.exp2data;
where prompt3cat12>=2 and fred1 in (1,2,3);
tables fred1*sliner /chisq;
run;**not sig;

proc freq data=w.exp3data;
where prompt3cat12>=2 and fred1a in (1,2,3);
tables fred1a*sliner /chisq;
run;** not sig;

proc freq data=w.exp4data;
where prompt3cat12>=2 and fred1a in (1,2,3);
tables fred1b*fred1a*sliner /chisq;
run;

/**** longitudinal effectiveness of speeding prompts ****/

PROC GLM DATA=p.exp5data ; CLASS promptcond_jul; 
MODEL deservedtotalq9q14_jul deservedtotalq9q14_aug =promptcond_jul; 
MANOVA H = _ALL_;
REPEATED WAVES ;  
where promptcond_jul=promptcond_aug; ; RUN; QUIT;

/**** effect of commitment on speeding ****/

proc glm data=w.exp4data;
where fred1b=2 and fred1a>=1 and fred2a>=1;
class fred1a fred2a;
model deservedtotal= fred1a fred2a fred1a*fred2a ;
lsmeans fred1a fred2a fred1a*fred2a/ pdiff=all adjust=tukey;
run;

/**** effect of commitment on accuracy ****/
proc freq data=w.exp4data;
where fred1b=2 and fred2a>=1 and edu3cat>=1 and ((fred1a=1 and s2=1) or fred1a=2) and deservedtotal>=1;
tables edu3cat*q14q20_true67*fred1a/chisq;
run;

proc logistic data=w.exp4data desc;
where fred1b=2 and fred2a>=1 and edu3cat>=1 and ((fred1a=1 and s2=1) or fred1a=2) and deservedtotal>=1;
class fred1a edu3cat/param=ref ref=first;
model q14q20_true67=fred1a edu3cat fred1a*edu3cat;
run;



/**** effect of commitment on straightlining ****/

proc means data=w.exp4data  mean;
where fred1b=2 and prompt3cat12>=2 and ((fred1a=1 and s2=1) or fred1a=2)and fred1a>=1 and fred2a>=1;
var sliner ;
class fred1a fred2a;
run;


proc logistic data=w.exp4data desc;
where fred1b=2 and prompt3cat12>=2 and ((fred1a=1 and s2=1) or fred1a=2);
class fred1a fred2a /param=ref ref=last;
model sliner=fred1a fred2a  fred1a*fred2a;
run;


/**** break-offs during freq/num questions ****/

 *** Exp1;
 ** only speeders;
 proc freq data=w.exp1data;
 where fred1>=1 and prompt3cat12>=2;
 table breakoff*fred1/chisq;
 run;

 proc freq data=w.exp1data;
 where fred1 IN (2,3) and prompt3cat12>=2;
 table breakoff*fred1/chisq;
 run;


 *** Exp2;
 ** only speeders;

 proc freq data=w.exp2data;
 where fred1>=1 and prompt3cat12>=2;
 table breakoff*fred1/chisq;
 run;

 
 proc freq data=w.exp2data;
 where fred1 IN (2,3) and prompt3cat12>=2;
 table breakoff*fred1/chisq;
 run;

 *** Exp3;
 ** only speeders;

 proc freq data=w.exp3data;
 where fred1a>=1 and prompt3cat12>=2;
 table breakoff*fred1a/chisq;
 run;

 proc freq data=w.exp3data;
 where fred1a in (2,3) and prompt3cat12>=2;
 table breakoff*fred1a/chisq;
 run;


 *** Exp4;
 ** only speeders;

 proc freq data=w.exp4data;
 where fred2a>=1 and fred1b=2 and prompt3cat12>=2;
 table breakoff*fred2a/chisq;
 run;



