options nolabel nocenter nodate formchar = '|----|+|---+=|-/<>*';
options fmtsearch=(work);
proc format ;
  value proga 1="academic"
              2="general"
	      3="vocational";
run;
data tobit;
  set 'd:/work/data/sas/tobit';
run;
proc means data = tobit maxdec=2 nonobs;
   class prog;
   vars apt read math;
run;

ods graphics  / reset=all imagename='dens' imagefmt=png
width=4in height=4in border=off;
proc sgplot data = tobit noautolegend;
  histogram apt;
  density apt /type = normal lineattrs=(color=blue);
run;

ods graphics  / reset=all imagename='hist' imagefmt=png
width=4in height=4in border=off;
proc univariate data=tobit noprint;
  histogram apt / midpoints=350 to 800 by 1 normal ;
run;

ods graphics  / reset=all imagename='mat' imagefmt=png
width=4in height=4in border=off;
ods graphics on;
proc corr data = tobit nosimple;
   var read math apt;
run;
ods graphics off;

* analysis part;
proc qlim data = tobit ;
  class prog;
  model apt = read math prog;
  endogenous apt ~ censored (ub=800);
run;

* preparing for hypothesis testing;
proc qlim data = tobit outest=t;
  class prog;
  model apt = read math prog;
  endogenous apt ~ censored (ub=800);
run;
proc print data = t noobs;
run;
* overall test;
proc qlim data = tobit ;
  class prog;
  model apt = read math prog;
  endogenous apt ~ censored (ub=800);
  test 'prog' prog_academic=0,
              prog_general =0;
run;

* test of equality;
proc qlim data = tobit ;
  class prog;
  model apt = read math prog;
  endogenous apt ~ censored (ub=800);
  test 'academic vs. general' prog_academic - prog_general = 0;
run;

proc qlim data=tobit ;
  model apt = read math prog;
  endogenous apt ~ censored (ub=800);
  output out = temp1 predicted;
run;

proc corr data = temp1 nosimple;
  var apt p_apt;
run;

