l*****o 发帖数: 61 | 1 有一组数据,数据结果如下:
Year FieldID Ntreatment Replication Nform Ntiming Yield
2009 ST001 100 1 AA Spring 182
2009 ST001 100 2 AA Spring 186
2009 ST001 100 3 AA Spring 176
2009 ST001 150 1 AA Spring 190
2009 ST001 150 2 AA Spring 198
2009 ST001 150 3 AA Spring 172
2009 ST001 200 1 AA Spring 200
2009 ST001 200 2 AA Spring 195
2009 ST001 200 3 AA Spring 196
2009 ST002 100 1 UAN SD 160
2009 ST002 100 2 UAN SD 165
2009 ST002 100 3 UAN SD 168
2009 ST002 150 1 UAN SD 180
2009 ST002 150 2 UAN SD 186
2009 ST002 150 3 UAN SD 179
2009 ST002 200 1 UAN SD 185
2009 ST002 200 2 UAN SD 189
2009 ST002 200 3 UAN SD 198
……
2012 ST200 100 1 UAN Fall 200
2012 ST200 100 2 UAN Fall 202
2012 ST200 100 3 UAN Fall 198
2012 ST200 150 1 UAN Fall 210
2012 ST200 150 2 UAN Fall 213
2012 ST200 150 3 UAN Fall 222
2012 ST200 200 1 UAN Fall 215
2012 ST200 200 2 UAN Fall 219
2012 ST200 200 3 UAN Fall 220
我需要用Proc Surveylogistic, Y变量为俩个NTreatment的产量差是否大于0(大于0
为1,不大于0为0), X变量为Nform, Ntiming。
但是首先我需要算产量差(比如150VS200).我用了以下SQL:
proc sql;
create table ylddiff as
select A.Year, A.FieldID, A.NForm, A.NTiming,
A.myield as Yld150,
B.myield as Yld200,
B.mYield-A.mYield as change
from (select year, fieldID, NForm, NTiming,
avg(Yield) as mYield
from work.Yield
where Nrate=150
group by FieldID
) as A
full join
(select year, fieldID, NForm, NTiming,
avg(Yield) as mYield
from work.Yield
where Nrate=200
group by fieldID
) as B
on A.year=B.year and A.FieldID=B.FieldID
;
quit;
但是我得到以下Error message: The query requires remerging summary
statistics back with the original data
而且得出的结果是每组数据都重复好几次。请问到底哪里出了错?怎么样才能一组数据
只出现一次 (每个地块fieldID的每个Ntreatment只出现一个平均值,而不是重复出现
3次平均值)? | k*******a 发帖数: 772 | 2 I guess you need group by year fieldID | l****u 发帖数: 529 | 3 proc sql;
create table ylddiff as
select DISTINCT A.Year, A.FieldID, A.NForm, A.NTiming |
|