1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 /* hungrymice.sas */
57 title 'Calorie restriction and Longevity in Mice';
58
59 /* Read data directly from Excel spreadsheet */
60 proc import datafile="/folders/myfolders/2453f15/StarvingMice.XLS"
61 out=mouse1 dbms=xls replace;
62 getnames=yes;
63 /* Input data file is StarvingMice.XLS
64 Ouput data table is called mouse1
65 dbms=xls The input file is an Excel spreadsheet.
66 Necessary to read an Excel spreadsheet directly under unix/linux
67 Works in PC environment too except for Excel 4.0 spreadsheets
68 Import of xlsx in Version 9.3 is buggy or I am doing something wrong. SAS Version 9.2
69 If there are multiple sheets, use sheet="sheet1" or something.
70 replaceIf the data table out1 already exists, replace it.
71 getnames=yes Use column names as variable names. */
72
73 /* proc print; */
74
75 run;
NOTE: The import data set has 349 observations and 2 variables.
NOTE: WORK.MOUSE1 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds
76
77 proc freq;
78 tables diet;
79
NOTE: There were 349 observations read from the data set WORK.MOUSE1.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.13 seconds
cpu time 0.12 seconds
80 proc means;
81 class diet;
82 var lifetime;
83
NOTE: There were 349 observations read from the data set WORK.MOUSE1.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.07 seconds
cpu time 0.07 seconds
84 data mouse2;
85 set mouse1; /* Now mouse2 is just mouse1, and we can
86 transform the data. */
87 diet0 = diet;
88 if diet = 'NP' then diet = 'Feed at Will';
89 else if diet = 'lopro' then diet = 'N/R50 lopro';
90 label lifetime = 'Life Length in Months';
91
92 /* By default, procedures use the most recently created SAS data table.
93 If you don't want this, use the data= option. */
94
NOTE: There were 349 observations read from the data set WORK.MOUSE1.
NOTE: The data set WORK.MOUSE2 has 349 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.04 seconds
95 proc freq;
96 title2 'Check Re-labeling of Diet';
97 tables diet * diet0 / norow nocol nopercent;
98
NOTE: There were 349 observations read from the data set WORK.MOUSE2.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.09 seconds
cpu time 0.08 seconds
99 proc glm;
100 title2 'Main analysis';
101 class diet;
102 model lifetime=diet / clparm; /* clparm gives CIs for contrasts down in
103 the estimate statements. */
104 means diet;
105 /* Estimate (like Contrast) uses alphabetical order: Be careful!
106 Feed at Will | N/N85 | N/R40 | N/R50 | N/R50 lopro | R/R50
107 Positive values of contrast mean longer life with less food. */
108 estimate 'Feed at Will vs. N/N85' diet -1 1 0 0 0 0;
109 estimate 'N/N85 vs. N/R50' diet 0 -1 0 1 0 0;
110 estimate 'N/R50 vs. R/R50' diet 0 0 0 -1 0 1;
111 estimate 'N/R40 vs. N/R50' diet 0 0 1 -1 0 0;
112 estimate 'N/R50 vs. N/R50 lopro' diet 0 0 0 1 -1 0;
113
114
115
116 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
128