在R中,函数table使用交叉分类因子来构建列联表。是否有一个等价的SAS过程可以重现这个R函数的结果?
示例:
x <- data.frame(x=rep(1:2,times=5),y=rep(1:2,each=5))
# output: x
# x y
#1 1 1
#2 2 1
#3 1 1
#4 2 1
#5 1 1
#6 2 2
#7 1 2
#8 2 2
#9 1 2
#10 2 2
table(x)
# output: table(x)
# y
#x 1 2
#1 3 2
#2 2 3发布于 2016-10-24 21:01:50
是,您要使用Proc Freq。
Proc freq data=mydata;
table x; *gives table of single variable;
table x*y; *gives a crosstab;
by z; *will give multiple tables based on levels of z;
run;3个例子。变量Diabetes_final和糖尿病,如果定义了糖尿病的任何一个亚型,则第二个变量被定义为1。
PROC FREQ DATA=ADS_R;
TABLE DIABETES_FINAL;
TABLE DIABETES;
TABLE DIABETES_FINAL*DIABETES;
TABLE DIABETES_FINAL*DIABETES/MISSPRINT LIST MISSING; ***SYNTAX FOR STRIPPED DOWN TABLE;
RUN;

https://stackoverflow.com/questions/40216924
复制相似问题