Sas - 保持Proc意味着按类别输出均值

时间:2014-03-21 01:42:21

标签: sas proc

data braindata;
infile "C:\Users\shockwavemasta\Downloads\brain-data.txt"
firstobs = 3 /* data starts on line 3, not on line 1 or 2 in the file*/
expandtabs /* change tabs into 8 spaces each */
pad; /* pads each entry with spaces as needed */
/* The variable names are taken from the file header.
E.g., @9 HourDrawn 3. means the value of the hour variable is           
located at column 9 and uses 3 characters to express the number.
*/
input @9 HourDrawn 3. @17 Sex $1. @22 Concentration 11.;
hr = HourDrawn;
run;

proc sort data = braindata out = brainmean_sorted;
by sex;
run;

proc means data = brainmean_sorted;
by sex; class hr;
output out=BrainMeans mean=mean;
run;

这就是我到目前为止所输出的,其输出的均值等于HR,这不是我想要的,当它应该采用每类hr的方法并保留值。我做错了什么?

目前看起来像这样:

enter image description here

当我希望它保留打印出的浓度值时: enter image description here

1 个答案:

答案 0 :(得分:0)

如其他地方所述,您需要一个VAR语句。

proc means data = brainmean_sorted;
by sex; class hr;
var concentration;
output out=BrainMeans 
mean(concentration)=mean;
run;