/* classicalpain.sas */ title "Pain data: Read from an Excel Spreadsheet"; proc import datafile="/folders/myfolders/Pain.xls" out=ouch dbms=xls replace; getnames=yes; /* Input data file is Pain.xls Ouput data table is called ouch dbms=xls The input file is an Excel spreadsheet. Necessary to read an Excel spreadsheet directly under unix/linux Works in PC environment too except for Excel 4.0 spreadsheets If there are multiple sheets, use sheet="sheet1" or something. replace If the data table already exists, replace it. Use this! getnames=yes Use column names as variable names. Beware of leading and trailing blanks if it's in xlsx format. */ proc print; /* Convert to univariate format, with 6 "cases" per patient. */ data arthritis; set ouch; Drug=1; Dose=1; Pain=Drug1Dose1; output; Drug=1; Dose=2; Pain=Drug1Dose2; output; Drug=1; Dose=3; Pain=Drug1Dose3; output; Drug=2; Dose=1; Pain=Drug2Dose1; output; Drug=2; Dose=2; Pain=Drug2Dose2; output; Drug=2; Dose=3; Pain=Drug2Dose3; output; keep Patient Drug Dose Pain; proc print; proc tabulate; title2 'Look at the means'; class Drug Dose; var Pain; table (Drug all),(Dose all) * (mean*Pain); proc glm; title2 'Classical mixed model repeated measures'; class Patient Drug Dose; model Pain = patient Drug|Dose; random Patient / test;