/* hungrymice.sas */ title 'Calorie restriction and Longevity in Mice'; /* Read data directly from Excel spreadsheet */ proc import datafile="/folders/myfolders/2453f15/StarvingMice.XLS" out=mouse1 dbms=xls replace; getnames=yes; /* Input data file is StarvingMice.XLS Ouput data table is called mouse1 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 Import of xlsx in Version 9.3 is buggy or I am doing something wrong. SAS Version 9.2 If there are multiple sheets, use sheet="sheet1" or something. replace If the data table out1 already exists, replace it. getnames=yes Use column names as variable names. */ /* proc print; */ run; proc freq; tables diet; proc means; class diet; var lifetime; data mouse2; set mouse1; /* Now mouse2 is just mouse1, and we can transform the data. */ diet0 = diet; if diet = 'NP' then diet = 'Feed at Will'; else if diet = 'lopro' then diet = 'N/R50 lopro'; label lifetime = 'Life Length in Months'; /* By default, procedures use the most recently created SAS data table. If you don't want this, use the data= option. */ proc freq; title2 'Check Re-labeling of Diet'; tables diet * diet0 / norow nocol nopercent; proc glm; title2 'Main analysis'; class diet; model lifetime=diet / clparm; /* clparm gives CIs for contrasts down in the estimate statements. */ means diet; /* Estimate (like Contrast) uses alphabetical order: Be careful! Feed at Will | N/N85 | N/R40 | N/R50 | N/R50 lopro | R/R50 Positive values of contrast mean longer life with less food. */ estimate 'Feed at Will vs. N/N85' diet -1 1 0 0 0 0; estimate 'N/N85 vs. N/R50' diet 0 -1 0 1 0 0; estimate 'N/R50 vs. R/R50' diet 0 0 0 -1 0 1; estimate 'N/R40 vs. N/R50' diet 0 0 1 -1 0 0; estimate 'N/R50 vs. N/R50 lopro' diet 0 0 0 1 -1 0;