options ps=60 nodate nonumber; data toxr1; infile 'N:\public_html\structured_data\toxr1.dat'; input group sex animal time day weight; run; /*---------------------------------------------------------- | The steps following fit a separate regression to the data | | for each animal, & saves the regression coefficients. | | (Into a file called tox_reg). The regression equation | | is : y = a + b*t . | -----------------------------------------------------------*/ title1 'RAT GROWTH DATA'; title2 '---------------'; proc sort; by animal group sex; proc reg outest=beta noprint; model weight = day; by animal group sex; run; /*-------------------------------------------------------- | Regression coefficients, for each animal, are saved in | | the above procedure into a dataset called beta. | ---------------------------------------------------------*/ data tox_reg; set beta; keep animal group sex day; run; proc print; title5 'Coefficients for terms in model : y = a + b*t'; run; /*---------------------------------------------------------- | Now analyse here the data on the regression coefficients | | using PROC GLM. | -----------------------------------------------------------*/ /*----------------------------------------------------------- | To look at the single degree of freedom contrasts amongst | | the treatments (groups) you will need to create new | | variables to identify the contrasts. | | | | The contrasts are : | | (i) A vs B at 100mg/kg/day | | (ii) High versus Low (100 vs Rest) | | (iii) Linear component using 0, 4 and 20mg/kg/da y | | (iv) Quadratic .. .. .. .. .. .. .. | | | | The variables which you need are set out in the box below.| -----------------------------------------------------------*/ data treatcon; set tox_reg; a_b = 0; hi_lo = 0; linear = 0; quad = 0; if group = 4 then a_b = -1; if group = 5 then a_b = 1; if group ne . and group <= 3 then hi_lo = -2; else hi_lo = 3; if group = 1 then linear = -1; if group = 3 then linear = 1; if group = 1 then quad = -1; if group = 2 then quad = 2; if group = 3 then quad = -1; run; proc glm data=treatcon; class sex; model day = sex linear quad a_b hi_lo sex*linear sex*quad sex*a_b sex*hi_lo / ss2; run; quit;