******************************************************************; *Author: Anand Vidyashankar ; *Title : rats_twostage_analysis.sas ; ******************************************************************; *Accesses the data set from the library ; libname rats "C:\Teaching_Fall 2004\Teaching\Fall_2006\ILRST711"; *Create SAS data set from the library; data one; set rats.rats; run; *Prints the SAS dataset; proc print data=one; run; *Sorts the dataset; proc sort data=one; by rat; run; *Prints the sorted data; proc print data=one; title "sorted data"; run; *This is first stage Analysis; *Regression analysis of for each rat; proc reg data=one; by rat; model y= t; *the following command obtains the parameter estimates for each rat and; *saves it in the sas data set called parms; ods output ParameterEstimates=Parms; run; *Prints the saas dataset named parms; proc print data=parms; title " First Stage Analysis"; run; *Remark: The parms data set does not contain the information about thetreatment; *We get this information from the data set one; data new; set one; keep rat treat; run; proc sort data=new; by rat; run; data new; set new; by rat; if first.rat; run; proc print data=new; run; *Notice that data set new contains the treatment information; proc sort data=parms; by rat; run; *Now we combine this information into the parms data and form; *data for second stage analysis; data second_stage; merge parms new; by rat; run; proc print data=second_stage; run; *Rearrange the data to perform second stage analysis; data second_stage; set second_stage; keep rat variable estimate treat; run; proc transpose data=second_stage out=os; by rat; run; data os; set os; if _name_="Estimate"; run; data os; set os; rename col1=b0i1 col2=b1i2; run; data os; merge os new; by rat; run; *Print the data for second stage; proc print data=os; title "transposed data"; run; * Multivariate analysis of results from stage1; proc glm data=os; class treat; model b0i1 b1i2=treat/nouni; manova h=_all_/etype=3 htype=3 mstat=exact; manova h=treat/etype=2 htype=2;; lsmeans treat; title "Results from second stage analysis"; run; *End of two-stage Analysis;