【问题标题】:Sas - Keeping Proc Means Output of Mean by ClassSas - 保持 Proc 意味着按类输出平均值
【发布时间】:2014-03-21 19:55:21
【问题描述】:
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 类的平均值并保留值。我做错了什么?

目前看起来是这样的:

当我希望它保留它打印出来的浓度值时:

【问题讨论】:

  • 感谢编辑!现在要是有人能帮帮我就好了哈哈
  • 请不要开始这样的新问题 - 你应该编辑你的其他问题。请立即删除其他问题。

标签: sas proc


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多