/* willow.sas */ options ls=72 ps=60; data willow; infile 'willow.dat'; input dbh area; sqrtdbh=sqrt(dbh); logdbh=log(dbh); if dbh=9.39 then delete; proc print data=willow; title 'willow data'; proc plot data=willow; plot area*dbh; plot area*sqrtdbh; plot area*logdbh; title 'willow example plots'; proc glm data=willow; model area=dbh/ ss1 ss2; output out=new1 p=yhat1 r=resid1; title 'regression of area on dbh'; proc print data=new1; proc glm data=willow; model area=sqrtdbh/ ss1 ss2; output out=new2 p=yhat2 r=resid2; title 'regression of area on square root of dbh'; proc print data=new2; proc glm data=willow; model area=logdbh/ ss1 ss2 p clm clparm; output out=new3 p=yhat3 r=resid3 lcl=clpl ucl=clpu lclm=clml uclm=clmu; title 'regression of area on log of dbh'; proc print data=new3; var area dbh clml clmu clpl clpu yhat3 resid3; data new; merge new1 new2 new3; proc plot data=new; plot resid1*dbh/vref=0; plot resid2*dbh/vref=0; plot resid3*dbh/vref=0; plot resid2*sqrtdbh/vref=0; plot resid3*logdbh/vref=0; title 'residual plots: (1) x=dbh (2) x=sqrt(dbh) (3) x=log(dbh)'; /* add data for plots */ data adddbh; input dbh area; sqrtdbh=sqrt(dbh); logdbh=log(dbh); cards; 2 . 4 . 6 . 8 . 10 . 12 . 14 . 16 . 18 . 20 . 22 . 24 . 26 . 28 . 30 . 32 . ; data willowplus; set willow adddbh; proc glm data=willowplus; model area=logdbh/ ss1 ss2 p clm clparm; output out=new4 p=yhat3 r=resid3 lcl=clpl ucl=clpu lclm=clml uclm=clmu; title 'regression of area on log of dbh (2)'; proc print data=new4; var area dbh clml clmu clpl clpu yhat3 resid3; /*create data set for plotting curve with data */ data new5; set new4; code = '*'; if area = . then code = '+'; newarea = area; if area = . then newarea = yhat3; proc plot data=new5; plot newarea*dbh = code; title 'plot of data and fitted model'; proc plot data=new5; plot newarea*logdbh = code; run;