Amandanannn 发表于 2016-1-23 11:38 
太赞了!!
还有个疑问,在使用Proc transpose的时候,如何确定prefix后面要加的名字是用 ...
All the values in the columns that are not "by" or _name_ or _type_ (or maybe some other columns created by SAS) will be transposed into one column with name defined by prefix.
In the following example, you will find that I created a column "a" in sbpflat before transposing and it will be transposed and included in column "sbp1".
At the same time, I also created a column "_type_", but it was ignored together with "_name_" by proc transpose.
Hope that answers your question.
data sbp;
input subject $ visit sbp;
datalines;
101 1 160
101 3 140
101 4 130
101 5 120
202 1 141
202 3 161
202 4 171
202 5 181
;
run;
proc transpose
data=sbp
out=sbpflat
prefix=VISIT;
by subject;
id visit;
var sbp;
run;
data sbpflat;
set sbpflat;
_type_="A";
a=visit1+visit3;
run;
proc transpose
data=sbpflat
out=sbp1
prefix=sbp;
by subject;
run;